best way to "lock" an arbitrary curve to the origin?

   487   2   1
User Avatar
Member
107 posts
Joined:
Offline
Hello. I'm wondering about if there is a quick, robust and procedural way to take any arbitrary curve in space that has at least normals and up vector and based on that curve's first or last point, first move it to the origin and then rotate it so that the normal will point straight down the z-axis (the N of the first/last pt)? Alternatively use the orient attribute to do the rotation if available?

please see the attached image

thanks,
Dag
Edited by Dougie0047 - Nov. 18, 2025 06:10:34

Attachments:
curve_lock_to_origin.jpg (274.6 KB)

User Avatar
Member
1184 posts
Joined: April 2017
Offline
Hi!

I usually use matrices to do this sort of thing. You already have 2 axis, you just need to create one more with a cross product. In a Detail Wrangle I used:

vector y = point(0, "up", 0);
vector z = point(0, "N", 0);
vector x = normalize(cross(z, y)); // getting the perpendicular vector
vector pos = point(0, "P", 0);
matrix m = set(x, y, z, pos);
setcomp(m, 0, 0, 3); // Making sur the last column has zeros
setcomp(m, 0, 1, 3); //
setcomp(m, 0, 2, 3); //
4@m = m;

...right after the wrangle, you place a "Transform_by_Attribute" sop with "m". Make sur you activate the "Invert Transform".
Edited by olivierth - Nov. 18, 2025 09:08:06

Attachments:
Houdini_reset_curve_to_origin_01.jpg (57.6 KB)
Houdini_reset_curve_to_origin_02.jpg (44.3 KB)

User Avatar
Member
107 posts
Joined:
Offline
Thanks for your reply oliverth! Transformbyattrib.. Interesting. I was not aware of this node
I'll try this out.
Thanks again.
Dag
  • Quick Links