Jump to content

Correct Rotations around Normal Axis


Recommended Posts

Hello,

 

I am stuck with how to correctly apply rotations to an object around its Normal. I have made a quick scene to try and show this. I know it is possible in the CopySop but I really need to do it in a Vop, but unfortunately my rotation matrix math is pretty bad. 

 

In the image below, if the xform node is bypassed, the rotations of the cubes is correct, but once I turn on the xform, the axis of rotation is off.

 

Would appreciate any help on this as it is something I have been fighting with for a while now and I've exhausted google.

 

Cheers

post-13980-0-28156400-1435768739_thumb.p

maketransfrom_individually_03.hipnc

Link to comment
Share on other sites

I'm sure there's a cleaner way, but this works.

 

You've saved the pivot for each cube as 'middle', which is copied to every point. I added normals to the grid driving the copy, and copy that to every point as 'Norig'.

 

I then

 

-subtract 'middle' from each point, which has the effect of moving every cube to the origin

-use a rotate vop with Norig as the axis, and rotate the cubes (I could only make the rotate vop work around the origin, hence the prior step)

-add 'middle' to each point, restoring the cube positions

 

Fairly sure there's a way to do the rotation in one step without the pre/post transform, but like you, my matrix maths failed me. :)

rotate_Norig.hipnc

Edited by mestela
Link to comment
Share on other sites

you can create your own transform with some vex aswell (only a few lines).

 

v@N will be our "y" and you can use v@up for your "x" or "z" vector. The copy node will use the two vectors(N and up) to copy geo with the correct transforms. 

 

in vex you can just use the rotate expression with our new matrix based on N and up. then you just redefine the v@N and up before the copy node.

 

this way you can have control over each copy geos rotation via @ptnum.

 

hope that's useful

 

ALSO NOTE: 

if you use houdini 13, be sure to cast the v@up to a [x,y,z] vector instead of a float vector, that way tthe transform node will update it properly. 

rotate_NandUp.hipnc

Edited by Alex Lombardi
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...