# Using Matrix to transform Geometry to origin

## Recommended Posts

A while ago I used some very simple Matrix multiplications to bring geometry, that is positioned anywhere in space, back to the origin and from there, back to its original position. Maybe anybody here can help me remember?

I think I created a world space transformation Matrix, called it myMatrix, and then multiplied it by its reverse to transform geo to the origin. In order to translate the geo back, I just multiplied by myMatrix...is that possible or am I getting something wrong? (Not in fromt of a Houdini right now)

Anyway, how do I get the world space transformation matrix for an object positioned anywhere in world space, for example for some geo that came into my scene as an ABC from Maya? Lookattransform in VOPSOPs?

Thanks for your hints and patience.

Edited by Phlok

##### Share on other sites

transform.hipncIt seems like nobody understands what I am trying to say and where I got stuck. So, I'll try again.

I've got an object_merge inside a GeoSOP, mimicking any geo that comes from an external source...abc, bgeo cache...anything.

Then I created a matrix attribute , myTransformMatrix in a PointVOP and did a Bind Export.

After that, I tried multiplying my points by the inverse of that matrix, but it doesn't seem to have any effect at all. I know I'm doing something wrong, but I'm stuck or blind (or both). In order to illustrate the sad truth, I uploaded an example file.

##### Share on other sites

II'm just starting to learn Houdini, so don't trust me much in this, but I saw this in a tutorial not so long ago.

You should need to create a coordinate system from your object (an up, front and side vectors) to create a matrix3, and then create a matrix 4 (m3tom4 node), isn't it? Then you can translate matrix4 with your object position (the centroid)

And is this matrix4 that you can multiply (inverted) in your second vopsop by the position to have the object in 0,0,0

Maybe doesn't have much sense. Just trying to help.

##### Share on other sites

I think this is what you try to achieve :

transform__001.hipnc

Edited by dedeks3000

##### Share on other sites

Gonna necro this, ive basically used pavel's example in some thread to move stuff back to origin.. So it can move the object based on the transform, i have 2 questions

1. Is this the proper way to do this? It feels like it can be simplified at least with connecting all those float to vectors.. Maybe a few lines of wrangle that can do all this easier? Pavel was doing more complex things so maybe theres additional steps i accidentally also copied.

2. Its obviously not a great solution to have to manually transform to the new (origin) position, I have the simple line thing built in the file which can easily be measured so no matter how many pieces there are you can just have a vec to the origin. How can that be used to bring the object back to the origin?

matrixv1.hip

##### Share on other sites

First off amazing example F1!!! Very nice lattice deformer.

Many ways to do this where you take the centroid of the input geometry, move to origin, do work then move back.

Using VOPs makes it artist friendly and re-usable.

Using Wranglers for those that like vex.

See the example file for both set-ups.

In the set-up, I do the easy thing and use the centroid() hscript function to fetch the origin of the input grouped geometry in to a declared vector parameter.

If you don't want to use the centroid() function (or \$CEX \$CEY and \$CEZ in the Transform SOP), you can use this vex code grabbed from the Expression Cookbook in the help http://www.sidefx.com/docs/houdini15.0/ref/expression_cookbook:

 Centroid `\$CEX`, `\$CEY`, `\$CEZ` ```v@min = {0.0, 0.0, 0.0}; v@max = {0.0, 0.0, 0.0}; getpointbbox(0, @min, @max); v@cent = (@max + @min) / 2.0; // @cent.x, @cent.y, @cent.z```

inverse_transform_example.hip

• 3

##### Share on other sites

Hey old school, I am back with another question. Perhaps this can also be made clear to me.. Lets say I have an object that is also rotated, in this case it is just in the transform node but hypothetically it can also be rotated from say a noisy particle sim that trails lines going in all directions.. And I want to be able to figure out that rotation angle and then when its brought back to the origin, have that rotation inverted and thus aligned in such a way that its now always pointing up in Y. Such as this diagram:

the file I attached isnt necessary to do it in there or anything, its the same as your example. I just wanted to avoid the expressions so it will just pack to get the centroid. I think this rotation thing would be super useful, scale doesn't seem like it would be necessary ever but perhaps if I have translation and rotation explained then scale is a good challenge to try on my own.

edit: and the reason I bring up the particle sim is so this can work on an all case basis, I can easily link the rotation in the transform node to the make transform vop rotation. But thats not as cool as it working for non transform'd rotations off the origin.

Thanks guys!

Edited by alksndr

## Create an account

Register a new account