I've recently been coding a quaternion class, for my game engine, and have run into a problem. Firstly, should I be using unit quaternions for my engine? Secondly, should I have the functions automatically normalise the quaternion, or should I leave it to the user?

What are the benefits and detriments for each of the possible options?


If your goal is to have quaternion that expresses rotations, and if you want to do operations with them (for eg. rotation composition by multiplying quaternions or convertion a quaternion to a rotation matrix), they must be unit quaternions, otherwise you may have unexpected results.

Quaternion normalization is a relatively costly operation involving squares and division and then should be avoided whenever possible to save CPU cycles.

Thanksfully, multiplication, for example as it is the most common quaternion operation, results in a unit quaternion when operands are unit quaternions themselves.

I would then recommend to let the user manually call normalization on a quaternion when he knows that the operation may have changed its length.

Hope it helps.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.