2

Quaternion Inverse and divider operator

The Inverse of Quaternion is very useful operator for object rotations or for dividing two quaternions, but it is not implemented yet. It can be calculated easely by multiplaing the x, y, and z component by -1.

Instead of Inverse oparator the UnaryNegation (-) already exists, but it is quite unuseful, because it multiplies all components by (-1), even W.

Please, implement that Inverse method and divider (/) operator too. 

Some other notes about quaternions:

The Quaternion.ToString() method prints the W component first and then X, Y, Z, which is a little confusing, if you dont know that. It should print in the same order as Vector.ToString(): X, Y, Z and then W.

The method SetRotation(Vector) doesnt accept Quaternion, only a Vector. The vector doesn't represent Euler rotation as someone would expect. I noticed that the component of a Vector are the same as for Quaternion, so the method should be called in this way:

SetRotation(new Sansar.Vector(quaternion.X, quaternion.Y, quaternion.Z, quaternion.W));

This is a little unpractical and is not documented yet.

4 comments

Please sign in to leave a comment.