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.

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.

• Gindipple

Yea that ToString() threw me off a bit early on.

and I've been carrying this around in each of my scripts for the other quirk

public Vector QuaternionToVector(Quaternion q)
{
return new Vector(q.X, q.Y, q.Z, q.W);
}

• Andrew Lawrence

Thanks Gindipple, for the last three weeks I had no idea why SetOrientation was making everything fail when I tried to use it.  Your example makes it obvious that it needs a quaternion in a vector object instead of a Euler vector, and now it works fine for me.

• Gindipple

Oh and don't make the dumb mistake I did and try to use Vector.Zero in SetOrientation()

It won't work and the exception thrown is eaten somewhere up the chain.

Very nasty one to track down.

• DoteDote

Yep, guilty of trying Vector.Zero in SetOrientation() myself. But looks like they fixed the need for that QuaternionToVector() function in the latest update: