Live data from Hacker News

Quaternions

liorsinai.github.io

31–40 of 118 posts

Re: Quaternions

#31

tldr: Simply explained without demonstrations: Quaternions are hypercomplex numbers of the form w + xi + yj + zk Where w, x, y, and z are real and i^2 = j^2 = k^2 = -1 and ij = k, ji = -k, jk = i, kj = -i, ki = j, ik = -j. Being u = (x, y, z) = xi + yj + zk a unitary vector, it is possible rotate any vector q by an angle theta around u by doing: pqp' where p = cos(theta/2) + sin(theta/2)u and p' = cos(theta/2) - sin(…

[deleted]

Re: Quaternions

#32

Ask HN: Do quaternions have any interesting properties, akin to those of complex numbers, when calculus is applied? The only application I've ever seen is for doing rotations in computer graphics.

Still mostly relevant to their use as encoding for transformations, but the fact that a unit quaternion's conjugate is also its inverse is extremely useful from a computational performance point of view.

Re: Quaternions

#33

tldr: Simply explained without demonstrations: Quaternions are hypercomplex numbers of the form w + xi + yj + zk Where w, x, y, and z are real and i^2 = j^2 = k^2 = -1 and ij = k, ji = -k, jk = i, kj = -i, ki = j, ik = -j. Being u = (x, y, z) = xi + yj + zk a unitary vector, it is possible rotate any vector q by an angle theta around u by doing: pqp' where p = cos(theta/2) + sin(theta/2)u and p' = cos(theta/2) - sin(…

> Quaternions are hypercomplex numbers of the form

I'm gonna guess "hypercomplex" means "involves imaginary numbers" due to the rest of this.

> Where w, x, y, and z are real and i^2 = j^2 = k^2 = -1 and ij = k, ji = -k, jk = i, kj = -i, ki = j, ik = -j.

Why even use different letters for i, j, and k, if they're all the same thing? Which thing appears to be i, as in, the square root of -1, that is to say, the most well-known and basic imaginary number, if I'm reading this right. As for the second part, I can't even begin to unravel the significance. I know it must not be, but it just seems like arbitrary rules added for... some unknown reason.

> Being u = (x, y, z) = xi + yj + zk a unitary vector, it is possible rotate any vector q by an angle theta around u by doing:

> pqp'

> where p = cos(theta/2) + sin(theta/2)u and p' = cos(theta/2) - sin(theta/2)u .

Oooooh kay... 1) Where'd w go? Is this one of those things where there's a (situationally-defined) constant in the formula but we just pretend it doesn't exist most of the time (until it comes time to actually use the math to, like, do anything real)? Would we need to bring it back in to apply the rest of this? 2) "u =" is just defining something, fine, but (x, y, z) doesn't seem to equal the thing after it at all—I suppose this is a shorthand function notation, though it seems really weird to me to use equality to relate that. Am I right, or is this something else?, 3) A quaternion is... a point, then? Since we're rotating around it? 4) I've got a feeling that theta needs a direction in this hypercomplex space but don't see where it's coming from. Somewhere "off screen", in this explanation? Or is it there but I'm not seeing it?

Re: Quaternions

#34

In my opinion, Geometric Algebra and bivectors ( https://bivector.net ) in particular is a much better (both practically and pedagogically) approach compared to quaternions and significantly more elegant. It's a real shame that people continue to focus so much on quaternions in this day and age.

Came here to say this!

I always felt like quaternions weren't a perfect fit for 3d rotation, and when I finally learned about bivectors my faith in the elegance of mathematics was restored :D

I liked this article: https://marctenbosch.com/quaternions/

Re: Quaternions

#37
post #21

Earlier quoted context omitted.

You can see what's wrong with that approach by considering the difference between traveling at constant speed along the arc of a circle versus traveling at constant speed along a chord, and projecting the point (out from the center) onto the arc. It works great if the chord is far away from the center (and also the angle is less than a half turn). If the chord goes through the center, it doesn't work at all.

10-12 years ago, the consensus used to be that this singularity simply does not show up in the wild in the vast majority of scenarios, and the performance hit of using `slerp()` is just not worth it unless truly needed. It was essentially the same reasoning as for using `-ffast-math`. Yeah it's not "correct", but users can't tell the difference and it has a measurable performance benefit. To be clear, I'm not questio…

Yeah, I understand. I just wanted to show that one can understand the exact nature of the approximation in 2D geometry.

I think it's useful to think of it as a separate category of "wrong" than -ffast-math, which is "wrong" because two expressions that are mathematically equivalent over real numbers, like a + (b + c) and (a + b) + c, are not equivalent over floating-point numbers.

Using lerp in place of slerp is like using x in place of sin(x). (The small-angle approximation) They're not equivalent over the real numbers.

Re: Quaternions

#38

tldr: Simply explained without demonstrations: Quaternions are hypercomplex numbers of the form w + xi + yj + zk Where w, x, y, and z are real and i^2 = j^2 = k^2 = -1 and ij = k, ji = -k, jk = i, kj = -i, ki = j, ik = -j. Being u = (x, y, z) = xi + yj + zk a unitary vector, it is possible rotate any vector q by an angle theta around u by doing: pqp' where p = cos(theta/2) + sin(theta/2)u and p' = cos(theta/2) - sin(…

tldr tldr (Since your version is for people who already understand undergraduate math, this version is for people who already understand upper-level undergraduate/graduate math):

If you try to use a product of 3 rotation matrices that represent rotations around fixed axes to represent rotations in 3D, there will inevitably be gimbal lock because there cannot exist a covering map from a product of 3 circles to SO(3). (Gimbal lock happens at the points where the map locally fails to be a covering map)

SU(2) is the universal cover of SO(3). The unit quaternions are a faithful representation of SU(2). Conveniently, the double cover map from SU(2) to SO(3) is dead simple in this representation: a unit quaternion q in SU(2) act on a purely imaginary quaternion (thought of as a vector in R^3) by conjugation. This is the formula you wrote.

Since it is a covering map, there is no gimbal lock.

Edited to fix explanation.

Re: Quaternions

#40

W.R Hamilton's discovery of the Quaternions is semi-famous itself, with the story being that after the critical flash of insight he carved the equation describing quaternion multiplication into a bridge in Ireland with a penknife. A interesting read is this letter [0] written the following day, where he explains his ideas in his own words. It's a great (and accessible!) look into his thought process. [0] https://www.…

The story goes that he was with his wife going to a dinner. On the way he got the flash of insight after years of working on the problem but he had no paper to write it down. When passing a bridge, he carved the equation on the side of the bridge to remind himself on the way back after the dinner.
Post reply on HN