Jump to content

How to Rotate a Non-Perpendicular Primitive to Align with the X-Axis?


Tomoka

Recommended Posts

Hi,

I’m currently working in Houdini and trying to rotate a non-perpendicular primitive to align it with the X-axis. In the second image, I used a Transform node and manually adjusted the rotation to achieve the alignment.

Is there a procedural or more accurate way to achieve this? Any tips, improvements, or alternative approaches would be greatly appreciated.

Thank you!

image.thumb.png.d2afe0c4818efd3b9fc479cbaf32ec8c.pngimage.thumb.png.ef311ea7b564df1cb1e403c326fc8120.png

 

Edited by Tomoka
Link to comment
Share on other sites

given two points on the long edge of the rectangle, let's say they're point 0 and 1:

 

vector p0 = point(0, "P", 0);

vector p1 = point(0, "P", 1);

vector n = normalize(p0 - p1);

// compute matrix that rotates the normalized edge onto +X

matrix3 d = dihedral(n, {1,0,0});

// transform points with this rotation

@P *= d;

  • Like 2
  • Thanks 2
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...