logoalt Hacker News

Matrix and Quaternion FAQ

26 pointsby signa11today at 4:41 AM6 commentsview on HN

Comments

xeonmctoday at 11:49 AM

The formulas provided for quat to matrix and quat to axis angle is terrible, they only work if the quaternion's magnitude is exactly one. You need to replace sqrt(1 - a*a) assumptions with actual components, and use atan2 instead of acos. I don't blame the author though because the vast majority of info you can find in online learning materials uses this ill-advised formulation, including Wikipedia. But it's really trivial to realize this fact if you just go ahead and derive from the quat sandwich from first principles and realize that the "convenience simplification assuming unit quat" is actually an unnecessary step that have no benefits and are wholly detrimental when implementing them for floating point numbers.

show 3 replies
fslothtoday at 2:01 PM

If you need this stuff in production I recommend getting a good computer graphics textbook.

These cheat sheets are convenient _if you already know what you are doing_ and _are confident the cheat sheet uses same presentation as your problem domain_.

That said I'm not sure if there is a nice book that would be both exact and practical at the same time.