Back to News
Advertisement
Advertisement

⚡ Community Insights

Discussion Sentiment

67% Positive

Analyzed from 215 words in the discussion.

Trending Topics

#quaternion#quat#instead#don#normalized#matrix#magnitude#exactly#need#replace

Discussion (3 Comments)Read Original on HackerNews

xeonmc•about 1 hour ago
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.
esperent•about 1 hour ago
> they only work if the quaternion's magnitude is exactly one

That's why you always normalize the quaternion first, and the article seems to require the normalized form:

Q.54 How do I convert a quaternion to a rotation matrix?

Assuming that a quaternion has been created in the form:

Q = |X Y Z W|

At least, I would read |X Y Z W| as meaning normalized(X Y Z W)

I don't see this notation explicitly defined when they describe quaternion normalization (Q.52) though, so I agree this leaves much out. It's more a cheat sheet than learning material.

> You need to replace sqrt(1 - a*a) assumptions with actual components, and use atan2 instead of acos

I'm kind of rusty with this, but I think the reason we don't do that is that it's cheaper to normalize then convert rather than use the non-normalized conversion formula. Correct me if I'm wrong.

DarkUranium•about 1 hour ago
Also, I really think we'd all be better off if we stopped using quaternions entirely and started using rotors instead.