0
votes

I have been working with Quaternions in UrhoSharp to do some 3D modelling work. I am having a confusion around the following code:

using Urho;

var q = Quaternion.FromAxisAngle(Vector3.UnitY, +45f);
var q2 = new Quaternion(0f, +45f, 0f);
var outputAngle = q.ToEulerAngles();
var outputAngle2 = q2.ToEulerAngles();

Console.WriteLine(outputAngle); // (0, -45, 0)
Console.WriteLine(outputAngle2); // (0, -45, 0) 

What I am not being able to understand is when I am creating the Quaternion with a +45 degree rotation around the Y axis, then how is the euler angle representation showing it is -45 degree.

Please note that I am from a non-gaming background and dealing with Vectors/Quaternions for the first time. So I do not have a good enough handle on the mathematics around Quaternions or Euler Rotations. I have read up a couple of posts but still not quite able to get my head around why the angle is getting reversed in the Euler representation.

1

1 Answers

0
votes

Euler angles can represent rotation in two distinct ways, converting from Euler to Quaternion (In the constructor) and back can give problems. A similar question is given here: Euler angle to Quaternion then Quaternion to Euler angle