Hacker News new | past | comments | ask | show | jobs | submit login

One reason to accumulate into quaternions vs a matrix is that compounded errors can add scaling and shear to a rotation matrix, whereas unit quaternions remain pure rotation (and non-unit quaternions can be trivially normalized).



That's reasonable, but compound matrix ops can also re-normalized and re-orthogonalized as they go, right? It's easier with a quat, for sure, but does it make up for the general complications with using quats?


I have not seen any complications of using quaternions that would be anywhere near as big as the complications of using any other approach.


That's why I posted an article that describes what the complications are, reference number [3] above. It's mainly a game-centric and people-centric view of problems with quaternions, not a list of technical problems with the representation. In short, many programmers don't understand quaternions, so using them puts an education burden on the team, a burden that is most frequently un-met. Quats can be less efficient, if you're not paying attention to what you're doing.


The part that is less efficient is applying a rotation to a vector (you need to "sandwich multiply" by your quaternion which involves 3×4 + 4×4 = 28 multiplications, whereas with a matrix you only need 3x3 = 9 multiplications).

But composing, interpolating, exponentiating, etc. is a lot nicer with quaternions. (Easier to reason about, numerically better behaved, computationally cheaper.)

If you need to apply the same rotation to a large number of separate vectors, keep your rotation representation as a quaternion internally and convert to a matrix just before vector rotation.


Many programmers don't understand matrices either. If you're going to be working with 3D engines, some of this stuff you'll just have to sit down and learn.


It depends a bit on the engine too. A long time ago I designed & built a multi-platform 3D game engine that used quaternions internally for many things, but exposed Euler PYR angles for most "game-level" object controls. We (the engine team) asked around and ended up deciding that the minuscule performance gain and better mathematical behavior from using quats everywhere would be more than offset by some of the devs being unable to reason about how the enemy ended up pointing the wrong direction, when looking at values in the debugger.


That is true, but it's safe to say that the number of people who do understand matrices is far greater than the number of people who understand quaternions. It's also worth pointing out that game engines and graphics APIs all deal in matrices, but don't all deal in quaternions. Mats can do what quats can do, but it's not true the other way around, quats cannot do everything matrices can do. Quats don't help with perspective, non-uniform scaling, or shear, just to name a few.


I don't think the "far" part is safe to say, not in this day and age.

Also, it is not really interesting what matrices or quaternions "can do". What is interesting is what we can do with them. And quaternions make a lot of things possible that are intractable or at least a huge pain with matrices.


> What is interesting is what we can do with them.

Yes, that was my point, that what you can do with quats is a strict subset of what you can do with 4x4 mats. Not sure what you thought I meant.

> quaternions make a lot of things possible that are intractable

Such as?


> compound matrix ops can also re-normalized and re-orthogonalized as they go

Certainly, but as you say it's a bit harder.

> does it make up for the general complications with using quats?

I'm sure that's context dependent, and don't have much of an opinion which way it's likely to break in general. I was just throwing something in the "pro" column that hadn't yet been discussed.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: