I have 2 normals, I want to get the difference between these 2 normals, so I have a new direction which would be the result of a (third direction + the difference of the initial 2).
Explanning a bit better:
I have NORMAL A and DIRECTION A
I have NORMAL B
I want to create DIRECTION B relative to NORMAL B, with the same angle DIRECTION A is based on NORMAL A.
The result you describe is ambiguous. You can create an extra vector from NORMAL B that has a similar angle to that normal B as the angle difference between NORMAL A + DIRECTION A. However, that vector can be rotated 360 around NORMAL B (around that vector) and keep the same angle between the two vectors. As such, many results are ‘valid’.
Thus I think the result you’d be getting isn’t exactly what you want.
But let’s give it a go using the Maya API.
import maya.api.OpenMaya as om
normal1 = om.MVector([0, 1, 0])
direction1 = om.MVector([0.5, 0.5, 0])
# Get the quaternion rotation between the two vectors
quat = normal1.rotateTo(direction1)
normal2 = om.MVector([1, 0, 0])
# Rotate the normal2 by a similar rotation
direction2 = normal2.rotateBy(quat)
print(direction2)
thanks a lot @BigRoyNL!
I understood what you meant, but I am planning to make an upvector to a similar direction, so they would match in the same orientation.
I will try your code and get back to you with the result.
thanks a lot!