3
$\begingroup$

I have these two perpendicular vectors that I want to align a cube to using geo nodes.

I can simply align it to the first one by using an Align Rotation to Vector node and throw the result in a Transform Geometry node. Then I can manually adjust a Rotate Rotation node set to Local space and get it to align with the second vector, but how do I calculate this value?

Here's my exact setup as of right now. I need to somehow calculate the value marked in red:

My geonode setup described above. Value that needs to be calculated marked in red

$\endgroup$

2 Answers 2

5
$\begingroup$

"Axes to rotation", takes two vectors. Does whatever possible to follow the second without breaking the first.

Nodes

Result

Angle between vectors

In case you're wondering, mathematically the angle between two vectors can be calculated in a few different ways.

The way I like to use in Blender is taking advantage of the cross product and dot product sizes. When the two vectors are normalized, the sizes are respectively the sine and the cosine of the angle between then, so the angle from v1 to v2 can be gotten like this:

Math nodes

It's worth noticing that "cross product" changes regarding the order of the inputs. If I put V1 first, I'm getting axis and angle for rotations "from V1 to V2". Inverting the order of the inputs inverts the direction of the output.

$\endgroup$
5
$\begingroup$

I would say the way to calculate the rotation angle is a mathematics problem, not a Blender question. But I guess you do not want the specific angle value, you just care for the alignment.

The Axes to Rotation node from the answer by @DanielMöller does what you want. By the way, normalizing the vectors is not necessary unless you specifically want that for placing the points. But for the alignment it does not matter.

Just in case you are working with an older version where the Axes to Rotation node does not yet exist, here is an alternative way: you can simply do that with two Align Rotation to Vector nodes:

The first one you leave as it is in your setup, where you align the Z axis with Pivot set to Auto to the first vector.

In the second Align Rotation to Vector node you align the X axis rotating around the Pivot Z axis (which you already aligned) to the second vector.

To be clear: Daniel's solution is correct and the most efficient. My alternative is for older Blender versions.

two align nodes

$\endgroup$
1
  • $\begingroup$ The rotation angel is a mathematics problem :D (self-destructing in...) $\endgroup$ Commented 15 hours ago

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.