Can someone please explain the math behind converting a direction-vector or lookAt-vector into a quaternion rotation?
What I am trying to do? I am trying to create a custom aim-constraint for a DCC (Maya. Also, Maya already provides one but I have reason to write a custom one). I have the world-space positions of eye and destination using which I can calculate direction vector but I need to calculate quaternion/euler rotation to rotate the object so that I can look at the destination.
What I found so far? There are couple of thread I found and read so far but some provide engine based approach, some do not provide explanation of math behind it and a few didn't work when converted into code. I am listing few of them here (for reference)
- https://gamedev.stackexchange.com/questions/149006/direction-vector-to-quaternion
- https://stackoverflow.com/questions/15873996/converting-a-direction-vector-to-a-quaternion-rotation
- https://answers.unity.com/questions/631836/how-i-can-converting-a-direction-vector-to-quatern.html
- http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/
- https://math.stackexchange.com/questions/1765799/convert-direction-vector-to-euler-angles
What I am Not looking for?
- way of calculating quaternion rotation from a (transformation) matrix.
- engine based approach eg:
Quaternion.LookRotation(relativePos, Vector3.up)
Thank you!