In geometry nodes how can I align instances to both a curve and ground plane?

2.2k Views Asked by At

Given this simple setup:

Node Tree

Viewport Preview

How can I align the planes instances such that the y axis of each plane is parallel to the curve, and the x axis of the planes are parallel to the ground plane (x and Y axis)?

I've tried various combinations with "Align Eular to Vector" node, but as soon as the curve does not face a specific axis the planes get tilted and the alignment to ground plane is lost.

any suggestions?

1

There are 1 best solutions below

0
MrW On

So after some research I found a solution to my own question. I'm posting it in case anyone else needs to find this out. Note that I'm not a mathematician and there might be a shorter solution (or specific nodes that I'm not aware of that can perform some of the steps). Also note that this is a solution for instances on a straight line which is what I was aiming for, I didn't test this setup on a curved line but my guess is that it will not work. For that you'll need to perform step 3 for every point or something like that.

Ok here we go:

  1. Generate instances on a line with the instance on point node.

  2. Auto orient the instances on the z axis with the align Euler to vector node based on the normal of the line.

  3. Calculate a vector between 2 points on the line (which point is not important since the line is straight but the order of the subtraction does!). To calculate the vector from point 1 to point 2 you'll have to subtract point 1 from point 2 (like so: point 2 - point 1).

  4. Calculate the angle between the new vector and the vector of the ground plane [0,0,1]. to do that use this formula:

    θ = arccosine ( dot product/ ( length(v1) * length(v2) ) ).
    
  5. Calculate the complementary angle which is 90 degrees - θ

*** convert 90 to radians of course

  1. rotate the instances on x axis by the result value.

Node Tree Result

If there is a shorter/easier solution, let me know.