- Home /
Axis, Angle in Quaternion.LookRotation()
From the doc page of Quaternion.LookRotation(), it is not clear to me what the value of the returned quaternion is.
A quaternion represents 3D rotation using 1] Axis of rotation & 2] Magnitude of rotation angle.
Given Quaternion.LookRotation(Vector3 forward, Vector3 upwards), what is the value of axis and angle in terms of forward and upwards.
Answer by Bunny83 · Mar 01 at 02:24 AM
Quaternions themselfs are always simply relative rotations, always. When they are used as absolute orientations, they are still relative rotations which are simply based on an initial orientation. The initial orientation is the default orientation. So simply aligned with the parent space / world space. So the quaternion will represent a rotation around an axis that brings you from the default / initial orientation to the target orientation. So for example Quaternion.LookRotation(Vector3.right, Vector3.up)
would be a rotation around the world up axis by 90 clockwise.
However for example:
Quaternion.LookRotation(Vector3.up, Vector3.right);
would be a rotation around the diagonal axis (1,1,1) and a rotation of 120°. If you have a physical cube (like a Rubik's cube), imagine holding the (1,1,1) and (-1,-1,-1) corners between two fingers and rotating the cube around that axis by 120°. You will notice that before the rotation when the blue side faces "forward", the red side faces "right" and the white side faces "up", after the rotation the blue side will face "up", the red side will face "forward" and the white side will face "right". Keep in mind that blue was the original forward and white was the original up. So they end up just as we requested. Since we rotate a cube around the corner diagonally and there are 3 sides meeting at a corner we have to rotate 3 times to make a 360° rotation and end up where we started. So rotating to the next face requires a 120° rotation.
So the actual axis and angle of a quaternion may not make much sense at first glance. However you always have to keep in mind that in 3d you can reach any orientation from any other orientation by rotating a certain amount of degrees around a single axis. This always works. That axis may have a seemingly strange alignment, but it actually works.
Your answer
Follow this Question
Related Questions
How can I angle an image along an line renderer and maintain a look-at-camera rotation? 0 Answers
How to rotate a character towards its movement direction for a walk on planet game? 0 Answers
Z axis up and X axis forward Rotation 0 Answers
Use curve effect on rotation? 1 Answer
Look rotation viewing vector is zero 1 Answer