4 ms·
Quaternions have a couple of advantages over matricies for pure rotations: 1. They're smaller - 4 floats - whereas you've got a minimum of 9 floats for a 3x3 r
by MaulingMonkey 6y ago
Quaternions have a couple of advantages over matricies for pure rotations:
1. They're smaller - 4 floats - whereas you've got a minimum of 9 floats for a 3x3 rotation matrix, or up to 16 floats (4x the size!) in some gamedev codebases with a single, general purpouse, 4x4 SSE optimized matrix.
2. They won't accumulate a skew or scale from floating point errors. At worst, you trivially renormalize a quaternion if it drifts too far out of scale, with only a few edge cases to worry about (0-length vectors, or nan/inf/denormal components.) While a matrix can be unskewed and unscaled with a few cross products and normalizations, there's more math and more edge cases to worry about.
You might transform those quaternions into temporary matricies to compose them with scale/translation/projection transformations for rendering, but you might not want to store your rotations as matricies.
- ogogmad 6y agoThe article author's suggestion to use 4x4 matrices suffers from all these same problems. Using a pair of quaternions would have all the same advantages.
- Aardwolf 6y agoThat's not what I mean, quaternions may have their specific advantages. But saying they avoid gimbal lock as if that's their exclusive feature (even though other simple methods, almost anything that isn't euler angles, can also avoid it) while leaving out the other advantages of quaternions is unfair to other methods and at the same time discredits the actual unique quaternion advantages.
- MaulingMonkey 6y agoYou're reading bolder claims into the quick contextualization in the preamble than I am. If I saw an earlier edit of yours correctly, you were using "must" when the article uses the weaker "should". And the article itself later admits "nothing about this technique is unique to quaternions" and compares vs matricies, without framing it as a contradiction of suprise in light of the aforementioned "conventional wisdom". I read the sentence in question as merely claiming: 1. Conventional wisdom says that you should represent your rotations as quaternions I would lightly agree with this - granted, for more reasons than just solving gimbal lock (hence why I brought some of them up) - but they're the right default, admittedly sometimes with exceptions. 2. quaternions avoid this [the gimbal lock] problem And I would lightly agree with this too - with the article pointing out the important caveat that you can't just construct 3 quaternions from your euler angles and assume that will fix your euler angle caused gimbal lock problems. You gotta use 'em right. ----- We agree that none of the following are true, nor "conventional wisdom": - quaternions must be used - quaternions are the exclusive solution to gimbal lock - the only distinguishing feature of quaternions is their ability to solve gimbal lock But I don't think the article was claiming any of those things. Perhaps an exhaustive sidebar into the various differences and pros/cons of various rotation methods could have been useful? My two reasons weren't exhaustive either! ... on the other hand, it also might be reasonable to practice restraint - keeping the article focused on a single topic, generalization into N dimensions of solutions to gimbal lock specifically? Non-exhaustive sidebar? ¯\_(ツ)_/¯