Page 1 of 1

Aligning one vector to another

Posted: Wed Apr 04, 2018 6:54 pm
by pfunkifized
I'm trying to align the normal direction to another direction vector and am having some difficulty getting it to work in Genome.

Here is where I'm at:
- I get the acos of the Dot product between the two vectors to get the angle
- I get the cross product and normalize it for the axis
- Then I convert this to quat using AngleAxisToQuat

So how do I actually "rotate" the Normal direction using this? I see a TransformByQuat node but I don't think I'm using it correctly.

Re: Aligning one vector to another

Posted: Thu Apr 05, 2018 2:29 pm
by Bobo
I am confused. Why do you have to rotate a normal vector to another verctor? Wouldn't it be enough to just grab the other vector, normalize it, and output as the value you want? A normal has a known lenght of 1.0, and you want the known direction of the other vector anyway. Unless you want to align gradually over time, of course...

Re: Aligning one vector to another

Posted: Thu Apr 05, 2018 4:32 pm
by pfunkifized
The idea is that one mesh is deforming and one is static. The artist wants to do all additional deformation on the static mesh since it is much easier to control, and be able to blend in these new deformations on the already deforming object.

My idea was to use something that could be relative even with deformation and thought that I could use the normal, rotate it to point in a direction that is stored in a mapping channel and move a certain distance ( also stored in a mapping channel ) to blend no matter how the object is deforming.

Does that make sense? Typing this out is harder than making the Genome!

Re: Aligning one vector to another

Posted: Thu Apr 05, 2018 5:10 pm
by Bobo
Again, if you know the direction already, there is absolutely no point in rotating the existing normal - just read the direction from the mapping channel, normalize it if needed, multiply by the distance, and move your Position by the result. Rotating an existing normal to match a known direction is just a waste of nodes.