8 ms·
Circa 90s and early 2000s. I like how there's a whole book on quaternions. I've never understood them and I'm convinced every definition I've read was written
by jessetemp 3y ago
Circa 90s and early 2000s.
I like how there's a whole book on quaternions. I've never understood them and I'm convinced every definition I've read was written by someone who also didn't understand them. I might try to find a copy if I ever dabble in 3d again
Edit: To clarify, I understand the need for quaternions (to avoid gimbal lock), just not how to use them manually. Euler angles are simple enough, I can change whichever axis by some degrees or radians. But with quaternions I never understood what was going on under the hood
- meheleventyone 3y agoWhilst a lot of those books are old, some are covering subjects like Quaternions that have been well understood for hundreds of years if not much longer. They're not necessarily lacking in value. There's a lot there that's pretty evergreen.
- dragontamer 3y ago> quaternions Instead of representing a rotation by roll, pitch, and yaw... you represent rotations by a 4x4 matrix. As this is a 3-dimension problem being represented in a 4-dimensional matrix, you have some weirdness to the math (IE: you need an additional constraint) but otherwise things get easier. --------- "Why is it easier?" Because roll / pitch / yaw systems have Gimbal Lock. That's... pretty much all you need to know as far as I'm concerned. Its a different system of representing rotations for reasons that the "classic" system messes up in. ------------ The math for quaternions is hard, but... who uses math these days? Just go into Blender, click the Quaternion button, and click the up/down buttons on the Quaternion matrix to see how the different values rotate the object. Once you practice both "classic" (pitch/yaw/roll) vs "quaternions" for... I dunno... 10 minutes? It becomes blatantly obvious that quaternions are easier to use. Its not even close. And I'm not sure if anyone has to implement the math of them anymore in any circumstances, so its just a matter of practicing them inside a 3d modeling program to see how to use it. After you've learned how to use quaternions, then you go back and learn the math behind it. If you care to. Or don't, its not like you need to know what the matrix represents exactly... --------- EDIT: Consider animation. If you've got an object that's rotating from (roll: 90-degrees, pitch: 90-degrees, yaw: 0-degrees), into (roll: 0-degrees, pitch: 180-degrees, yaw: 90-degrees), and you change this by going... (90, 90, 0) (89, 91, 1) (88, 92, 2) ... (2, 178, 88) (1, 179, 89) (0, 180, 90) Did the object rotate and "look" correct in all frames? Now do the same with the 4x4 matrix quaternion. This is all just a simple click in Blender + animation keyframes. Does the object look better? Weird crap happens in the roll/pitch/yaw form. Weird in ways that's difficult to describe in words, but easy as crap to see in 30-seconds of Blender. So just pull out a 3d modeling program and look at the damn thing, its really obvious.
- andersa 3y agoA quaternion is not a 4x4 transformation matrix. In game development context, it usually refers to a structure consisting of 4 floats and is always assumed to be normalized. Maybe reading this comment helps: https://news.ycombinator.com/item?id=37527928#37529562 https://news.ycombinator.com/item?id=37527928#37529562
- lobf 3y agoI love that the replies are kind of reinforcing OPs point that nobody seems to understand
- alex_lav 3y agoSounds like they're the gamedev equivalent of a Monad? Which I only vaguely understand as a result of a poster on this forum's "Everyone explains it wrong" style post. Hoping you get a similar response with this.
- Animats 3y agoQuaternions tend to be over-complicated. Basic concept, 1 dimensional form: you want to represent a direction in a 2D plane. You can use one number, a heading angle, but at some point you reach a full circle and the number has to wrap. This creates annoying special cases. So another approach is to use a 2D vector, a point on a circle. Those are usually normalized so that x^2 + y^2 = 1. No angle is "special". You can average and filter such vectors without problems, for example. This is called a homogeneous representation, because it behaves the same everywhere in its space. Now upgrade to 2D - latitude and longitude. Near the poles, small positional changes cause huge latitude changes, and computation error increases. This is a serious problem in navigational systems. So it's common to represent latitude and longitude inside of GPS systems as a 3-component vector, a point on a sphere, in what's called "Earth-centered, earth fixed" form. Now you can average or difference measurements without special cases. (Yeah, WGS-84 to compensate for planet not being a perfect sphere, etc.) Now upgrade to 3D orientation. That's a quaternion. It's a point on a 4-dimensional hypersphere. This can be mapped to a 3D vector pointing in space and a roll around that vector, or to pitch-roll-yaw, etc. As above, a quaternion is a unit vector. It's hard to visualize this, so just shut up and calculate.
- andersa 3y agoWow, I had never seen this explanation before. That makes so much sense! Now I finally understand why we always normalize the quaternions and why that is a sensible operation...
- pclmulqdq 3y agoI am going to be the HN pedant here, and for that I apologize. Quaternions don't specifically need to be unit vectors or points on a 4-D hypersphere. They are any number with 3 imaginary parts and 1 real part. Being a unit operator is a property of a rotation (this holds true even if you aren't using quaternions or if you extend to n-dimensional rotations), not a property of quaternions.
- zerr 3y agoInstead of Euler angles, you use one axis and one angle, because the former has a limitation named as "gimbal lock".
- hknapp 3y agomakes it easier when you understand complex numbers https://www2.clarku.edu/faculty/djoyce/complex/ https://www2.clarku.edu/faculty/djoyce/complex/
- smcameron 3y agoOne thing to know about quaternions is that you do not need to understand them in order to know how to use them, much as you do not need to understand how an automatic transmission works in order to drive a car. The knowledge of how to use them is completely separable from the knowledge of why they work, and if you concentrate on the former, and don't worry about the latter, much progress can be made. Edit to add: When I say "you don't need to understand how they work to use them", I mean, you can literally implement all the math to multiply, conjugate, scale and invert quaternions from basic math operators and floating point numbers in C, and use those operations to rotate 3d objects around in your program successfully, all without having any idea why they work. I know this, because I have done it. The basis for my understanding how to use quaternions, and how to build the basic operations on them comes from this site, which is quite concise and dense, but contains the necessary information if you can beat your head against it persistently: http://www.tutis.ca/Rotate/7quaternions.htm http://www.tutis.ca/Rotate/7quaternions.htm
- eestrada 3y agoMy (poor) understanding of quaternions is they are like a vector with a rotation angle around the axis of the vector. This is probably incorrect on many levels. But it was a simple enough explanation that it made sense to my brain why this would work better than simple SRT transform parameters for avoiding gimbal lock. It's been several years since I needed to deal with 3D transformations of any sort, so I'm a bit rusty on all this.
- xeonmc 3y agoUltimately, the “canonical” representation of rotation state is still axis-angles, thanks to Euler’s rotation theorem (any combo of rotation results in just one rotation around some final axis) (normalized) Quaternions are just the intermediate representation of axis-angles, they describe the component-wise algebra of combining axis-angle rotations [Euler-Rodrigues formula](https://en.wikipedia.org/wiki/Euler–Rodrigues_formula https://en.wikipedia.org/wiki/Euler–Rodrigues_formula) Game engines just leaves them as quaternions for performance reasons. A 2D analogy would be “angle” <-> [quaternion] “45deg” <-> [sqrt2 , sqrt2] The [ Re , Im ] form is convenient for manipulating by coordinates, but the “final” succinct representation is still “angle”, because the component-wise form has more degrees of freedom than necessary. Summary: Quaternion = sqrt( exp(axis_angle) ) = exp(axis_angle/2) = cos(angle/2) + axis*sin(angle/2) And (lw,lx,ly,lz)*(rw,rx,ry,rz) = (w,x,y,z) where w = ww-xx-yy-zz x = wx+xw+yz-zy y = wy+yw+zx-xz z = wz+zw+xy-yx where ww,wx,wy,wz = lw*rw,lw*rx,lw*ry,lw*rz xw,xx,xy,xz = lx*rw,lx*rx,lx*ry,lx*rz yw,yx,yy,yz = ly*rw,ly*rx,ly*ry,ly*rz zw,zx,zy,zz = lz*rw,lz*rx,lz*ry,lz*rz
- okaleniuk 3y agoWe used quaternions in our engine back in 2005-2008. Compared to matrix multiplications, multiplying quaternions was cheaper so we could save a few instructions here and there. But I never used them since. One reason being, I suppose, processors are now much more superscalar-friendly so a matrix multiplication doesn't take much more time than a quaternion multiplication does. And with matrices, you get the whole package: not only rotations, but translations, scalings, and even projections, - all in one go. So you have simpler code, simpler data structures, and you don't lose performance so... why bother? I didn't even include quaternions in my book. Well, not that I didn't want to. We had a whole discussion with the publisher about whether we should keep the whole chapter (complex numbers, conformal transformations, non-commutative 3D rotations, and quaternions) and I lost.
- aap_ 3y ago> I've never understood them and I'm convinced every definition I've read was written by someone who also didn't understand them This seems about correct. The book in the list also seems to fall into that category. Quaternions are actually really simple and pretty once you understand them. The idea is that you specify and axis and an angle. The axis alone gives you a 180° rotation. 1 is the identity and gives you no rotation. If you interpolate between those on a circle (cos/sin) you can get any rotation around that axis. One may wonder why one needs the sandwich product to rotate a vector when simple multiplication is enough for complex numbers. The reason is that in 2D there is only one plane of rotation and all vectors lie in it. In higher dimensions vectors can be decomposed into a part that lies in the plane of rotation and a part that's orthogonal to it (parallel to the axis in 3D) that is untouched by the rotation. With the sandwich product the quaternions cancel out for the orthogonal part but combine for the part in the plane. This also makes it obvious you have to take half the angle. Finding the quaternion that rotates between two vectors is also easy. You just multiply them, then take the square root to get the half-angle. Taking the square-root is extremely simple: assuming your quaternion is normalized, you just add 1 and renormalize! Obviously this doesn't work if that quaternion is -1 (can't normalize 0), but it makes sense geometrically: a 360° rotation (-1) is the same around any axis so no axis can be recovered, but for its square root (180°) you have to pick one. It's just not well defined. Of course all of the above can be shown with a few lines of algebra, and with geometric algebra the whole thing becomes even cooler.
- powerpiglet 3y agoThere's an alternate concept for rotations called a rotor that is just as capable as the quaternion concept but does not require reasoning in higher dimensions: http://marctenbosch.com/quaternions/ http://marctenbosch.com/quaternions/