Need help understanding Quaternion.AngleAxis
Hi everyone,
I thought Quaternion.AngleAxis would create rotations that are perpendicular to the axis that you specify as parameter. But I didn't get that behaviour.
Here is my simple code snippet:
void Start()
{
axis = new Vector3(1f, 1f, 1f);
axis.Normalize();
Quaternion rot = Quaternion.AngleAxis(350f, axis);
Debug.Log(Quaternion.FromToRotation(Vector3.up, axis).eulerAngles.ToString());
}
I specified the Vector3(1f, 1f, 1f) as desired rotation axis. I then ran the script a few times, each time with a different angle value in order to visualize which rotations AngleAxis created:
Quaternion.AngleAxis(70f, axis);
Quaternion.AngleAxis(140f, axis);
Quaternion.AngleAxis(210f, axis);
Quaternion.AngleAxis(280f, axis);
Quaternion.AngleAxis(350f, axis);
I converted the resulting rotation to eulerAngles (in the Debug.Log statement), created a new object after every run of the script (all objects parented to the WORLD) and inserted the euler angles in the rotation fields of the object's inspector.
The result can be seen here, with the rotation axis in orange:
What I had expected instead (warning: aligned manually, so not perfect!):
Where's my faulty reasoning? What haven't I understood about the way AngleAxis works?
Thanks so much for any help!
Sean
Your answer
![](https://koobas.hobune.stream/wayback/20220612062227im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Gimbal Lock Problem 1 Answer
Quaternions to EulerAngles weird x-axis interaction 1 Answer
Quaternion.Angle() unexpected output. Compare to Vector3.Angle() which produces correct values. 0 Answers
How can I find direction with known 2 projection angles on xz and yz planes? 2 Answers
How to add to a rotation angle? 0 Answers