8 ms·
Rediscovering Quaternions
- pvg 2y agoRelated a few weeks ago https://news.ycombinator.com/item?id=42880242 https://news.ycombinator.com/item?id=42880242
- matmann2001 2y agoNot 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?
- aap_ 2y agoBecause quaternions are so cool yet under-appreciated. Unfortunately not many octonion posts.
- rsfern 2y agoOctonions 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 https://doi.org/10.1016/j.actamat.2018.12.034 (Open access pdf: https://par.nsf.gov/servlets/purl/10098941 https://par.nsf.gov/servlets/purl/10098941) Can you give some pointers to other interesting applications?
- mikhailfranco 2y agoFundamental physics: https://www.quantamagazine.org/the-octonion-math-that-could-underpin-physics-20180720/ https://www.quantamagazine.org/the-octonion-math-that-could-... Also see the work of John Baez: html https://math.ucr.edu/home/baez/octonions/octonions.html https://math.ucr.edu/home/baez/octonions/octonions.html pdf https://math.ucr.edu/home/baez/octonions/octonions.pdf https://math.ucr.edu/home/baez/octonions/octonions.pdf
- Jarmsy 2y agoI have noticed too that HN has an enduring fascination with quaternions, and they seem to reach front page surprisingly frequently (considering that there's not a huge amount of discussion of other geometry topics). I'm certainly not complaining though - I love quaternions too!
- mettamage 2y agoMaybe because it intersects deeply with game dev?
- lawlessone 2y agoyes, that's the module i learnt about them in during college. IMHO I think for me they're interesting because it felt like mathematically they straddle the line of being nearly impossible for me. I could just barely do them and felt very accomplished when I could. Anything else was either impossible or easy by comparison. assuming my maths skills are average here then most people have similar experiences with them.
- xanderlewis 2y agoWhat in particular did you find difficult about dealing with them?
- lawlessone 2y agoThere was something called a slerp that allowed you to get an object to rotate from on orientation to another, similar to a linear interpolation. This was fine for some things. but if you wanted something to rotate but only in a certain way it was annoying as sometimes it would get from A to B, but go through Z during its rotation. Getting the order or multiplications right too.
- ahazred8ta 2y agoSpherical linear interpolation, slerp https://en.wikipedia.org/wiki/Slerp https://en.wikipedia.org/wiki/Slerp (which can sometimes wrap around the wrong way) For levity, see Acts 12:4 And when he had apprehended him, he put him in prison, and delivered him to four quaternions of soldiers to keep him.
- hassleblad23 2y agoBecause quaternions are awesome? :) it definitely feels like a discovery when you learn about them first.
- gamedever 2y agoAre they? [Let's remove Quaternions from every 3D Engine] https://marctenbosch.com/quaternions/ https://marctenbosch.com/quaternions/
- xeonmc 2y agoI feel like there should be a followup post "Dear Sir, you have reimplemented quaternions" noting how implementing GA and using it only in 3D gets you precisely right back to quaternions-but-with-a-different-name since they're isomorphic when specialized for 3D.
- orangea 2y agoAt least this is a topic that the average HN reader is likely to be able to understand and which is closely related to software. Several years ago there was a period where there were periodic posts about things like homotopy type theory and research-level algebraic geometry which inevitably spark only inane misunderstandings and uninformed speculation in the comments. I can only attribute it to some kind of fetish for the frontiers of pure math.
- kisonecat 2y agoAG maybe isn't so connected to software, but HoTT connects to the "functional programming" crowd. https://youtu.be/MVtlD22Y8SQ https://youtu.be/MVtlD22Y8SQ is me doing some examples.
- adalacelove 2y agoIt's because the quaternion is part of the state of the Kalman filter.
- ballooney 2y agoNot in any intrinsic way, it’s just a mildly better way of representing attitude if your state vector includes attitude.
- TaurenHunter 2y agoThey are posted by the Quaterminions.
- paulddraper 2y agoQuaternions and spherical trigonometry - https://news.ycombinator.com/item?id=42880242 https://news.ycombinator.com/item?id=42880242 - Jan 2025 (48 comments) Visualizing quaternions (2018) - https://news.ycombinator.com/item?id=38043644 https://news.ycombinator.com/item?id=38043644 - Oct 2023 (42 comments) Visualizing quaternions: an explorable video series (2018) - https://news.ycombinator.com/item?id=31083042 https://news.ycombinator.com/item?id=31083042 - April 2022 (15 comments) Visualizing quaternions: An explorable video series - https://news.ycombinator.com/item?id=18310788 https://news.ycombinator.com/item?id=18310788 - Oct 2018 (32 comments)
- ofalkaed 2y agoI never noticed it until I read Pynchon's Against the Day, I assume I just ignored quaternion posts before then. Great book, enjoyed the way he used quaternions and vectors towards literary ends. Edit: just noticed we also have a thread on bifurcation, another big topic in Against the Day.
- mhh__ 2y agoThey're both simple to motivate and complicated enough to have an allure.
- ballooney 2y agoThey’re both quite basic building blocks in state estimation and as SV’s focus shifts from web apps to drone warfare it will only increase in frequency.
- gcr 2y agono worries, quaternions just make the usual rotations. It’s cyclic.
- esafak 2y agoMaybe it's aspirational: things that people don't know, and would like to learn, and perhaps use one day.
- defrost 2y agoHN'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.
- mbonnet 2y agoOthers have mentioned game dev, but they're also essential for guidance, navigation, and control - spacecraft, aircraft, robotics, etc.
- r1chardnl 2y agoIf I had to describe Quaternions to someone I would first try to explain a Plane (Ax + By + Cz + D = 0) to them. ABC being a (normal) direction that the Plane is pointed towards and D being the distance from the origin. A Quaternion from what I believe is just the same but instead of distance it just encodes the rotation around that direction as a fixed axis. (Instead the angle stored is half etc). Feel free to correct me if I'm wrong, I'm not a math-heavy person.
- adamhartenz 2y agoIf you a explaining this to the average American, you are going to have to start a bit further back than a "Plane".
- raincole 2y agoI know it's a tradition to bash Americans, but I'm quite sure in any country, Ax + By + Cz + D = 0 is a plane isn't common sense.
- renox 2y agoI learned it in the mandatory part of school (I'm French) so while I'm sure lots of people have forgotten it, most did learn it at school..
- grg0 2y agoThink of a fraction as a pizza. The bottom number is how many slices the pizza has, and the top number is the slices that you are going to eat. Sally will eat the rest, so you need to leave some for her.
- ge96 2y agoIn the beginning... there was nothing...
- xanderlewis 2y agoA plane is just a burrito.
- aithrowawaycomm 2y ago> These discontinuities are not just an artifact of poor implementation; it can be proven that any representation of 3D rotations using only three values must contain discontinuities. This is a bit pedantic - and the blog post actually does clarify this - but the problem isn't that a 3D representation of representations has "discontinuities" as such, it's that it's not orientable in Euclidean 3D space. It is similar to the Klein bottle - the mathematical description is continuous, but any Klein bottle made of real-world glass has to intersect itself. Or likewise that a Mobius strip can be demonstrated in 3D but can't be built in Flatland without a 3D entity doing the copy-pasting. Reality just has the wrong topology to represent the full group of rotations. Hence the discussion about projective space later in the blog post. So adding a fourth gimbal is really tantamount to a correctly-oriented embedding of 3D rotations onto a 4-torus (that is, [0,2pi]^4). Gimbal lock also relates to another issue of continuity, related to the "plate dance."[1] Rotations themselves have a sense of continuity (infinitesimal differences in either the angle or axis of rotation, aka they are Lie groups), but Euler angles fail to respect the equivalent fundamental theorem of calculus: adding a bunch of infinitesimal changes might say you are at the identity rotation according to Euler angles, but in reality you have flipped the meaning of the right-hand rule and the overall state of the system is not at the identity. In a robotics context, the robot's hand might have done a complete rotation, but its arm is twisted without the robot "knowing." I believe robotic arms used to have a serious problem with this, either overrotating and breaking the arm, or swinging dangerously fast in the opposite direction. Using quaternions / a fourth gimbal / etc. there would be a measurable phase or pole indicating the true state of the system, and letting the robot know how to rotate its arm without malfunctioning. So, like the Apollo mission, the need for a fourth dimension to keep track of that stuff - and even the quaternion multiplication structure - comes about pretty naturally without ever thinking about abstract math. [1] https://en.m.wikipedia.org/wiki/Plate_trick https://en.m.wikipedia.org/wiki/Plate_trick
- tagrun 2y agoThat statement is also incorrect. 1. "any representation of 3D rotations using only three values" That is not representation, that is parametrization. Euler-angle parametrization sometimes fails because it is not a correct parameterization of SO(3) in general by construction, this is why it sometimes fails (essentially, the three consecutive rotations can sometimes effectively collapse into two for certain set of angles, regardless of how you choose your 3 axes, in which case you can't relate 2 independent parameters back to the 3 independent axis-angle parameters). The correct parametrization of SO(3) is the axis-angle parametrization, which can be represented using quaternions or 3D reals matrices. The "representation", on the other hand, would typically be unit quaternions or 3D orthogonal matrices. 2."it can be proven that any representation of 3D rotations using only three values must contain discontinuities." where is that proof and what discontinuity are you talking about? It sound like he misunderstood what "SO(3) is not simply connected" means. Lie groups are differentiable. 3 parameters are sufficient to represent any 3D rotation. The natural parametrization of all Lie groups, including SO(3), is the axis-angle parametrization, and their elements have the form exp(i θ n.J) where n is a unit vector defining the axis of rotation, θ determines the amount of rotation, and J is a vector of the generators of the corresponding Lie algebra. The "regular" 3D matrix representation in the axis-angle parameterization is obtained with so(3) generators L_x, L_y, L_z in their fundamental representation. Basis quaternions i, j, k (which can be represented by Pauli matrices) obey the same Lie algebra as L_x, L_y, L_z, but the group that it corresponds to (which is SU(2)) is a double cover of SO(3) (up to a sign), so they can still be used for implementing 3D rotations once you pick a sign.
- cantalopes 2y agoI was hoping thered be more of actual quaternions
- nighthawk454 2y agoThe easiest way for me to conceptualize it is to think of it as orientation + rotation. 3 dims for the orientation vector to get the object facing/pointing the right way, then a further 1 dim/var for rotation about that axis. For a total of 4 variables/dimensions 3blue1brown and Ben Eater did a series of interactive videos on the subject that can be explored: https://eater.net/quaternions https://eater.net/quaternions My favorite demo on this point is this one: https://eater.net/quaternions/video/rotation https://eater.net/quaternions/video/rotation Where they have a toggle to go between `a + bi + cj + dk` quaternion notation and an equivalent formulation in terms of 3d orientation vector plus rotation angle as `cos(θ) + sin(θ)*(ai + bj + ck)`
- deleted 2y ago[deleted]
- tsarakoye_selo 2y agoWhat happens if rotation is zero? Won't (ai +bj+ ck) get multiplied by zero then, and the orientation information is lost?
- nighthawk454 2y agoIf you click through to the interactive example, you can try it! You'll see that the if the above equations are `q`, then full formula to rotate a vector `v` is `v' = q * v * q^-1`
- tsarakoye_selo 2y agoSorry, what you have stated is not very clear. If you use cos(theta) + sin(theta)*(ai + bj + ck) representation as you mentioned, what does happen to the orientation information when sin(theta) becomes zero
- moefh 2y agoWhen theta=0, you have q = cos(0) + sin(0)*(ai+bj+ck) = 1 + 0 = 1 That means applying the "rotation" to the vector gives v' = q * v * q^-1 = 1 * v * 1^-1 = v So the output ("rotated") vector is the same as the input, as you would expect for a rotation by 0.
- agnishom 2y agoI 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.
- Sharlin 2y agoGA gives rise to the bivector representation of 3D rotations, mentioned in passing by the author of TFA.
- LegionMammal978 2y agoWhile 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?
- cjbgkagh 2y agoFor 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.
- jfantl 2y agoQuaternions 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.
- chefandy 2y agoHoudini 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 https://github.com/toadstorm/MOPS
- Ygg2 2y agoWhenever I see a quaternion post, I wonder why the rotors aren't the default[1]. They are mathematically equivalent, easier to explain, can generalize to higher dimensions, and aren't mocked in the Alice in the Wonderland[2] (famous tea part scene). [1]https://archive.is/20240820193111/ https://archive.is/20240820193111/ (mirror of https://marctenbosch.com/quaternions/ https://marctenbosch.com/quaternions/ ) [2]https://gaupdate.wordpress.com/2011/07/26/quaternions-part-of-the-hidden-math-behind-alice-in-wonderland/ https://gaupdate.wordpress.com/2011/07/26/quaternions-part-o...