
Identity Quarternions (Bug)
Posted Sunday, 29 June, 2008 - 04:44 by Kamujin inIf I try to convert an identity quaternion to a matrix4, I get an error. Matrix4 = NAN.
This is due to the axis being equal to 0,0,0 I believe.
Shouldn't this return Matrix4.Identity instead?
// : IEquatable<Quaternion> public bool Equals(Quaternion other) { return W == other.W && XZY.X == other.XYZ.X && XZY.Y == other.XYZ.Y && XZY.Y == other.XYZ.Z; } public static Matrix4 Rotate(Quaternion q) { if (q.Equals(Quaternion.Identity)) return Matrix4.Identity; Vector3 axis; float angle; q.ToAxisAngle(out axis, out angle); return Rotate(axis, angle); }


Comments
Re: Identity Quarternions
actually I think the bug is in the Quaternion ToAxisAngle function. It's not returning a normalised axis when the quaternion is the identity.
Mr Fiddler: could you update the function in question to read
Re: Identity Quarternions
That makes sense also. I was not sure how the ToAxis was supposed to behave in the case of Quaternion.Identity.
Thanks.
Re: Identity Quarternions
Fiddler, can you let us know what your thinking on this issue?