Live data from Hacker News

Quaternions

liorsinai.github.io

21–30 of 118 posts

Re: Quaternions

#21
post #4

I've been out of the games sphere for a long time, but is slerp() really the default idiomatic interpolation approach in modern games nowadays? There are a vanishingly small number of scenarios where lerp() + normalize() doesn't work perfectly well enough and it is drastically faster and SIMD-friendly. That used to be the case at least.

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 questioning using slerp() at all, it definitely has a role to play. I'm just wondering about using it by default as implied by the post.

Re: Quaternions

#22
I remember the first time I encountered quaternions, and it was in a similar context. I was using PiQT 3d to move models in a simulation.

At first it really bothered me that quaternions were a black box to me, yet so easy to use in so many contexts. What kind of magic was happening? I had to know.

My math is terrible. I spent actual days revisiting YouTube videos explaining quaternions but my limited brain cells were failing to properly grasp it. I had to know though, I’d go crazy writing so much code that depends on something I couldn’t understand.

It took a long time. This would have been very helpful. Quaternions are very cool, and well worth reading about if you do anything in the digital 3d world.

I think I can still hear my brain sizzling as I tried to absorb this stuff.

Re: Quaternions

#24
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.

Re: Quaternions

#25

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(…

I don't believe that most people will consider that "simply explained".

Re: Quaternions

#26
This page is a little more information dense, but it's what I learned quaternions from (after bashing my head against it for a couple of weeks) and it's good as a refresher because it is so dense.

http://www.tutis.ca/Rotate/7quaternions.htm

One thing I didn't see in the OP's linked article is how to transform a quaternion into a different coordinate system defined by another quaternion. For example, suppose you have a spaceship in a game at an arbitrary orientation defined by Q1 which is a rotation away from a conventional "unrotated" orientation, and you want to input say 5 degrees of yaw to the right. Well, you just construct a quaternion Q2 that is 5 degrees yaw to the right from this conventional unrotated orientation, and you can use quaternion conjugation to transform Q2 into the orientation of Q1 where it can then be applied to the spaceship's orientation. OP's link mentioned quaternion conjugation, but didn't really mention what it was good for. It is described in section IV of the 7quaternions link.

Re: Quaternions

#27
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.maths.tcd.ie/pub/HistMath/People/Hamilton/QLette...

Re: Quaternions

#28

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(…

I don't believe that most people will consider that "simply explained".

Maybe succinctly?

Re: Quaternions

#29
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.
Post reply on HN