Skip to content

Instantly share code, notes, and snippets.

@Kif11
Last active April 26, 2024 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kif11/0674b75e8d6f90a4151539d67dc0f6bf to your computer and use it in GitHub Desktop.
Save Kif11/0674b75e8d6f90a4151539d67dc0f6bf to your computer and use it in GitHub Desktop.
Rotate flat geometry to X/Z plane. Houdini VEX.
// Align object to target vector base on selected normal
// Useful when object has some weird orientation baked
// in the mesh and you wan to straighten it up.
// Point with normal from second wrangler input to align
vector from = point(1, 'N', 0);
// Allign "from" normal to the following vector
vector to = {0,1,0};
matrix3 m = ident();
float amount = acos(dot(from, to));
vector axis = normalize(cross(from, to));
rotate(m, amount, axis);
@P = @P * m;
@N = @N * m;
@Kif11
Copy link
Author

Kif11 commented Jun 21, 2019

Screen Shot 2019-06-21 at 2 35 31 PM

@yjsp93
Copy link

yjsp93 commented Jul 5, 2023

Thanks a lot. you save me

@Kif11
Copy link
Author

Kif11 commented Jul 5, 2023

@yjsp93 glad it is useful.

@BerStepan
Copy link

It works very good, thx a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment