Live data from Hacker News

Rediscovering Quaternions

jasonfantl.com

31–40 of 72 posts

Re: Rediscovering Quaternions

#31

Not detracting from this post, but has anyone else noticed there's a front page post about Quaternions or Kalman filters on about a monthly cadence? Wonder why that is?

Because quaternions are so cool yet under-appreciated. Unfortunately not many octonion posts.

Re: Rediscovering Quaternions

#32

I also recently came across "Geometric Algebra", which seems like an idea of equipping a vector space with a formal anticommutative product. There seems to be a subset of people on the internet who swear by it.

GA gives rise to the bivector representation of 3D rotations, mentioned in passing by the author of TFA.

Re: Rediscovering Quaternions

#33
post #31

Not detracting from this post, but has anyone else noticed there's a front page post about Quaternions or Kalman filters on about a monthly cadence? Wonder why that is?

Because quaternions are so cool yet under-appreciated. Unfortunately not many octonion posts.

Octonions are cool! The one application I’m familiar with is in crystallography - you can represent the interface between two crystals with a unit octonion https://doi.org/10.1016/j.actamat.2018.12.034

(Open access pdf: https://par.nsf.gov/servlets/purl/10098941)

Can you give some pointers to other interesting applications?

Re: Rediscovering Quaternions

#34
While they might be theoretically pleasing, I've had trouble seeing the appeal of quaternions for 3D graphics. Recently I was working on some 3D-rendering code from scratch for a project, and I looked into using quaternions for rotation, only to scratch my head at how fiddly they were to apply to vectors. (Also, many resources talking about them focus on their abstract properties at the expense of actual examples, which is annoying when I'm just trying to implement them.)

I had a much simpler time just using rotation matrices for everything. They're not much more difficult to compose, they're trivial to apply to vectors, and they can be easily understood in terms of their row and column vectors. (For my project in particular, I really enjoyed the property of easily knowing which octants the basis vectors are mapped to.)

Where are the practical areas where quaternions shine? Are they just useful for the slerp operations that everyone points at, or are there other situations where they're better than rotation matrices?

Re: Rediscovering Quaternions

#35

While they might be theoretically pleasing, I've had trouble seeing the appeal of quaternions for 3D graphics. Recently I was working on some 3D-rendering code from scratch for a project, and I looked into using quaternions for rotation, only to scratch my head at how fiddly they were to apply to vectors. (Also, many resources talking about them focus on their abstract properties at the expense of actual examples, wh…

For 3D graphics I think the main issue quaternions helps with is for interpolations. Depending on your use case that may or may not be important to you.

Re: Rediscovering Quaternions

#36

While they might be theoretically pleasing, I've had trouble seeing the appeal of quaternions for 3D graphics. Recently I was working on some 3D-rendering code from scratch for a project, and I looked into using quaternions for rotation, only to scratch my head at how fiddly they were to apply to vectors. (Also, many resources talking about them focus on their abstract properties at the expense of actual examples, wh…

Quaternions can be useful in robotics when you're trying to perform trajectory planning or any kind of rotation control. Quaternions provide a continuous space where every point represents a rotation, unlike rotation matrices, which exist in a much harder space to explore since most matrices do not represent pure rotations. If you have algorithms for example trying slerp between rotations, or find a path from one rotation to another under some constraint, or sample rotations near the current rotation, then the space of quaternions is a much more practical space to work in.

Re: Rediscovering Quaternions

#37

Not detracting from this post, but has anyone else noticed there's a front page post about Quaternions or Kalman filters on about a monthly cadence? Wonder why that is?

HN's going to need a windscreen cleaner and a bucket if 3blue1brown and Terence Tao ever collaborate on using adaptive Kalman filters for optimal paths in Quaternion spaces.

Re: Rediscovering Quaternions

#38

While they might be theoretically pleasing, I've had trouble seeing the appeal of quaternions for 3D graphics. Recently I was working on some 3D-rendering code from scratch for a project, and I looked into using quaternions for rotation, only to scratch my head at how fiddly they were to apply to vectors. (Also, many resources talking about them focus on their abstract properties at the expense of actual examples, wh…

Quaternions are automatically orthogonal, whereas matrices can shear and therefore may accumulate floating point distortions under repeated opreations.[0]

Think of matrices as computational instructions, which are straightforward but lossy, while quaternions are the canonical "lossless representations".

The sweet spot for using quaternions is to use them as intermediate representations of rotation operations, then "compile" them down to a matrix once you are gonna apply it to a vector.

    ijkl_as_matrix = {
        (ll+ii)-(jj+kk), (ij+ji)-(lk+kl), (ki+ik)+(lj+jl),
        (ij+ji)+(lk+kl), (ll+jj)-(kk+ii), (jk+kj)-(li+il),
        (ki+ik)-(lj+jl), (jk+kj)+(li+il), (ll+kk)-(ii+jj),
    };
(Keep in mind that unnormalized quaternion has uniform scaling, so if your quats are unnormalized then your matrix will also apply a scale factor of dot(q,q), so you should divide your final vertex coords by that factor.)

---

[0] For an example, see https://old.reddit.com/gdd8op

Re: Rediscovering Quaternions

#39

While they might be theoretically pleasing, I've had trouble seeing the appeal of quaternions for 3D graphics. Recently I was working on some 3D-rendering code from scratch for a project, and I looked into using quaternions for rotation, only to scratch my head at how fiddly they were to apply to vectors. (Also, many resources talking about them focus on their abstract properties at the expense of actual examples, wh…

Houdini is all quaternions under the hood— purportedly to avoid gimbal lock. Houdini’s thing generally is doing things the hard way if there’s any possibility it could lead to a better outcome. Unfortunately, without a (fortunately open source at the free-level) plugin, doing things like rotating a bunch of objects on their own local axes means wrangling the quaternions directly in code.

If you’re interested in seeing their approach, here’s the repo:

https://github.com/toadstorm/MOPS

Re: Rediscovering Quaternions

#40
post #38

While they might be theoretically pleasing, I've had trouble seeing the appeal of quaternions for 3D graphics. Recently I was working on some 3D-rendering code from scratch for a project, and I looked into using quaternions for rotation, only to scratch my head at how fiddly they were to apply to vectors. (Also, many resources talking about them focus on their abstract properties at the expense of actual examples, wh…

Quaternions are automatically orthogonal, whereas matrices can shear and therefore may accumulate floating point distortions under repeated opreations.[0] Think of matrices as computational instructions, which are straightforward but lossy, while quaternions are the canonical "lossless representations". The sweet spot for using quaternions is to use them as intermediate representations of rotation operations, then "c…

Does leaving them unnormalized affect their numerical accuracy? A few sources [0] [1] suggest renormalizing often, but I'm not sure whether it's just dogmatic or if it's actually necessary. It definitely seems less involved than re-orthogonalizing matrices, in any case.

(Luckily, for my project, I'm not particularly worried about error, since the only thing being rotated frequently is the camera, and microscopic scaling and shearing won't affect the result much. I measured the error in the basis vectors over time to make sure, and it just seems to be O(sqrt(t)) random-walk noise, not anything that compounds on itself.)

[0] https://www.tobynorris.com/work/prog/csharp/quatview/help/or...

[1] https://stackoverflow.com/a/12934750

Post reply on HN