7 ms·
Exponentially Better Rotations
- ResNet 5y agoSeeing Euler's formula [1] elegantly come into play was very satisfying! Posts like these are why I love HN. [1] https://en.wikipedia.org/wiki/Euler's_formula https://en.wikipedia.org/wiki/Euler's_formula
- deleted 5y ago[deleted]
- eatbitseveryday 5y agoAh I thought this would be a written piece about medical students' third and fourth years of their teachings :)
- cattleprodigy 5y agoI highly recommend this paper for a more in-depth treatment of exp/log map and the related representation of transformations: A Micro Lie Theory by Joan Sola, Jeremie Deray, Dinesh Atchuthan https://arxiv.org/pdf/1812.01537.pdf https://arxiv.org/pdf/1812.01537.pdf
- JadeNB 5y agoA warning, though: trying to switch from a mathematician's idea of Lie groups and algebras to a physicist's, or anyone else's, is not easy. I am a mathematician with a research specialty in Lie groups, and I remember being asked a question about this paper—I can't remember what it was, or I would be more specific—a while ago that was mathematically easy to answer, but where most of the time it took me to answer was spent in decoding the notation. This treatment is closer to the mathematician's than to the physicist's, but it still has some of the physics flavor about it—for example, it at least implicitly discusses Lie groups as if they come with a preferred action, which they need not—and, if you're not in this domain already, it's good to know what difficulties you can face later if you try to move between domains.
- andi999 5y agoFrom reading on mobile (so might have missed the clarification) it also seems to do the standard mistake in physics literature to assume the exponential map is surjective so the log map is defined on the whole group (which they call M?). This is not always true, I think sl2(R) is an example of a connected, non compact group such that the exponential map is not surjective.
- chombier 5y agoThanks, I just realized I was also assuming exp to be surjective as well, I stand corrected. The Wikipedia page[1] mentions the issue briefly but I was curious of the counter-examples. IIUC, matrices in SL(2) with trace < -2 have two distinct eigenvalues, one of which is negative[2], and such matrices cannot be reached by exponentiating elements of the Lie algebra sl(2) (traceless matrices). [1] https://en.wikipedia.org/wiki/Exponential_map_(Lie_theory)#Surjectivity_of_the_exponential https://en.wikipedia.org/wiki/Exponential_map_(Lie_theory)#S... [2] https://en.wikipedia.org/wiki/SL2(R)#Classification_of_elements https://en.wikipedia.org/wiki/SL2(R)#Classification_of_eleme...
- chombier 5y agoI found this nice accessible proof for the interested: https://planetmath.org/slnrisconnected https://planetmath.org/slnrisconnected
- andi999 5y agoIs this part of the proposition: x=exp X, and x having a double eigenvalue implying that X has a double eigenvalue somehow clear? How do you prove it?
- dimatura 5y agoYeah, about 10 years ago I was reading one of the earliest papers applying these ideas to computer vision and I was pretty confused, as I never had any exposition to Lie group/algebras in my engineering undergrad. So I tried to read mathematical texts on this subject and I was 100x more confused! Would have been useful to article like the GP's one back then.
- dllu 5y agoI wrote another blog post on the topic, with lots of pictures and simple explanations: Intro to Lie groups for rigid rotations https://daniel.lawrence.lu/blog/y2021m07d14/ https://daniel.lawrence.lu/blog/y2021m07d14/
- tgv 5y ago> lots of pictures and simple explanations Just some observations on that: - a random picture of Le petit Prince doesn't make it easier to understand - there's a huge difference between people that don't know that you'll end up in the same place if you keep walking on a sphere and those that won't quit at "closure: A \oplus B is still in the group". - "Rotations in 2D" doesn't explain things, it just states them. It requires reasonable understanding of all concepts. - There are also detractors, like "However, locally, they are like \mathbb R^1, a trivial 1-dimensional Euclidean space." It isn't clear why that is meaningful. This is not meant as criticism, just to point out that the entry level for your blog might be higher than you think/intended.
- dllu 5y agoThanks, very useful feedback!
- jessriedel 5y agoIs dllup able to generate equation references with named labels, like the way LaTeX uses \label and \ref? (I looked at the "References" section of the dllup documentation, and it looks like you have to know the equation number that is going to get generated, e.g., #eq3., but I'm wondering if there is alternative syntax.) If not, is there an alternative format for putting math on the web that you like that supports this? (Just asking in case I ever move away from my ancient Wordpress installation with the QuickLaTeX plugin.)
- dllu 5y agoWhen compiling dllup to LaTeX, it is possible to just use \label but I haven't implemented that functionality in dllup to html yet. You can also consider pandoc's markdown flavor that supports equations and references: https://pandoc.org/MANUAL.html#pandocs-markdown https://pandoc.org/MANUAL.html#pandocs-markdown
- liamkinne 5y agoInteresting is how this applies to interpolation with industrial robotic arms. Shortest path for each joint moving from a -> b does not create a linear path for the end-effector of the robot. Linear end-effector movements require inverse kinematics and are limited by how fast the slowest joint can move. Quaternions are also useful because you often don’t care the particular rotation you approach and object with, just the angle/direction so you can leave theta as an arbitrary value.
- hgomersall 5y agoThe real nugget in all that is the geometric algebra link towards the bottom, almost as a throwaway. It would be nice if that was expanded in the same way as the rest of the sections.
- ogogmad 5y agoThe dual-complex numbers have a similar use-case. You can use them to interpolate between two rigid body motions in 2D. There's some interesting infinity/infinitesimal phenomena there, with translations (a type of rigid body motion) being represented as rotations whose centre point is at projective infinity and whose angle of rotation is infinitesimal. The name of the number system is unfortunate though, I have to admit. In spite of all this, I haven't heard of anyone using these for anything. I do though have a use-case for a problem I'm working on. I also wrote the Wikipedia article on DC numbers, so I'm kind of biased here.
- enkimute 5y agoThese are also called the planar quaternions and are the even subalgebra of 2D PGA. I use and explain these (and their nD generalisations) in my SIBGRAPI 2021 talk on kinematics and dynamics in PGA. https://youtu.be/pq9YfdPHhIo https://youtu.be/pq9YfdPHhIo There is also a writeup called 'may the forque be with you' available on bivector.net
- ogogmad 5y agoLooks like there's been some progress on this front since I last looked. Maybe Wikipedia needs to be updated.
- HellDunkel 5y agoGreat post. The rendering applets dont seem to work in Firefox. Safari an Chrome both work great.
- Aethylia 5y agoApplets work well on firefox desktop for me.
- unwind 5y agoSame, unusable on Chrome/Android, using the first horizontal slider scrolls the entire page, then the text rendering went completely nuts. Had to close the page.
- shirleyquirk 5y agoFor me, on Android, Firefox works(enough), Chrome doesn't.
- Agentlien 5y agoI enjoyed this article and thought it gave a nice summary of techniques for rotation. It did leave me with a feeling of skepticism towards a few of its points. Most of all I feel like I don't understand the usefulness of the defined map. The article does admit that computing and interpolating quaternions is very practical. The one use case given for this map over quaternions is averaging a set of rotations. This isn't something I've regularly had to do. The closest I can think of is handling multiple competing orientation constraints in a physics solver. This is something we did at my first job and while I didn't look closely at the code I know it was neatly handled using quaternions.
- dimatura 5y agoI've worked a fair bit with 3D data in a robotics context, mostly from the perception side but also a tiny bit on the motion side (and grad coursework). In practice you have to deal with pretty much all the representations, they all have their pros/cons and in some cases more than one works fine, so different libraries will use different representations and you have to convert back and forth all the time (a fun source of bugs!). In an academic context, I feel like the community has converged on matrix exponential representation. One reason, I think, is that it's fairly good for optimization with gradient-based approaches, which is useful on its own but also meshes well with deep learning tools that are increasingly becoming more common for 3D perception (and motion planning) tasks.
- Agentlien 5y agoI work with game development and used to work in medical simulation. Most projects I've been on use primarily matrices for most transforms with quaternions used to handle pure rotations, transformed to matrices at the last possible stage.
- orlp 5y agoAll of this touches on maybe 1% of the potential of geometric algebra: https://bivector.net https://bivector.net I would strongly suggest watching some talks about it: https://bivector.net/doc.html https://bivector.net/doc.html For example a rigid body simulator in n-D in ~40 LOC, 20 of which are boilerplate defining the points of a cube: https://youtu.be/5R2sv9GCwz0?t=371 https://youtu.be/5R2sv9GCwz0?t=371 (in an environment that defines the geometric algebra for you - but only that, it's no different than using a library that provides quaternions for you, for example). This is possible because geometric algebra is powerful enough to unify and interpolate not just rotations as one object, but generalize rotations, reflections and translations (and more) as one object (a motor), embedded in an algebra unifying position, velocity, (angular) momentum, torque and force. If it doesn't make sense how that works, watch the earlier talks in the series. And it gets more general, the above talk is about PGA which embodies flat (object) Euclidean geometry, but CGA also embeds spheres and circles in the algebra, allowing any conformal transformation to be represented natively in the algebra. This is very powerful for (inverse) kinematics in robots with fixed rotating arms, for example: https://www.youtube.com/watch?v=j2x_TG8E3_k https://www.youtube.com/watch?v=j2x_TG8E3_k
- Asooka 5y agoThe problem for me is that, as a computer scientist, I'm focused on the numerical representation of things. Geometric algebra is presented by omitting that until the last second and instead focusing on abstract concepts and how they fit together. For example, they say "A vector is an oriented scalar value" and that already confuses me. Obviously I know what a scalar is, a scalar is one number, but what is "oriented"? Is it N numbers for the e0,...,en-1 axes? Is it N^2 numbers forming a rotation matrix? Is it just N numbers for the vector and we only call it "oriented"? I would like to see geometric algebra explained from the bottom-up - starting from the numerical representation of the objects they talk about and explaining how it gives rise to the properties they're looking for.
- chriswarbo 5y ago> Obviously I know what a scalar is, a scalar is one number Hang on, is that a Natural number, or a signed Integer? Is it place-value, and if so what's the base? Big- or little-endian? Is it fractional, and if so is it a rational (numerator and denominator), or fixed-point (what precision?), or float (how big's the mantissa?); maybe it's a unum? How about a sequence of continued fractions? This is tongue-in-cheek; but from a software perspective, all those representations have the same "API" (arithmetic). Likewise, geometric algebra is an "API"; that's essentially what an algebra is.
- jessriedel 5y agoIs the math rendering in this blogpost done using Jekyll and AcademicPages, as described here https://kevinfossez.github.io/posts/2020/04/blog-post-1/ https://kevinfossez.github.io/posts/2020/04/blog-post-1/ Or is it something else?
- chombier 5y agoWhat made the Lie exponential click for me is the definition of exp as a limit: exp(x) = (I + x / n)^n when n goes to infinity. A tangent vector x at the identity is split in n chunks, each chunk is added to the identity to get a matrix (I + x / n). Each of these matrices gets increasingly closer to the group as n increases, and these n matrices are composed together to approximate exp(x), in a similar fashion to forward Euler integration with n iterations and integration step 1/n. The actual formula ends up being the usual power series and is useful for computations, but I find the limit above really captures the essence of how the exponential works.
- Damogran6 5y agoThank you for giving me spinning cows to start my day. And Matrix math, holy cow (heh), it's been a long time since I needed that.
- xaedes 5y agoOh you can absolutely average rotation quaternions, even weighted. You just use regular online computation of mean, express it in terms of linear mix operations (x k + (1-k) y) and then use quaternion slerp for the linear mix: mean = zero_rotation_quaternion wsum = 0 for w,qt in zip(weights, quaternions): wsum += w # regular online mean computation: # delta = qt - mean # mean := mean + delta*w/wsum # express as linear mix: # mean := mean + qt*w/wsum - mean*w/wsum # mean := mean * (1-w/wsum) + qt*w/wsum # i.e. mean is linear mix between mean and qt, with k=w/sum mean = slerp(mean, qt, w/wsum) return mean
- chombier 5y agoExcept the quaternion product is non-commutative, so the result of your algorithm will depend on the ordering of your `quaternions` array (which may be acceptable in practice), whereas Karcher mean does not.
- scythe 5y agoThe quaternion product is non-commutative, but quaternion addition is commutative. As far as I can tell he just takes weighted averages, which is a commutative operation. Rotations in 3D are inherently non-commutative, so whenever you work with multiple axes, the order matters. Interpolating between two rotations is a special case because you're not actually rotating the rotation operators themselves.
- chombier 5y ago> As far as I can tell he just takes weighted averages, which is a commutative operation. It works when doing LERPs (linear interpolations) but the algorithm above uses SLERPs (spherical interpolations) which can be expressed with quaternion products/exponentials/logarithms, so I think the order does matter. A quick numerical check with 3 quaternions and uniform weights seems to confirm this.
- xaedes 5y ago
- kilovoltaire 5y agoIf you want an inspiring (imho) overview of the power of geometric algebra, I thoroughly enjoyed the video "A Swift Introduction to Geometric Algebra" https://youtu.be/60z_hpEAtD8 https://youtu.be/60z_hpEAtD8
- tzs 5y agoThe formulation in that of Maxwell's equations as a single simple GA equation was pretty cool. I was curious though about how it would change if magnetic monopoles were discovered, but did not pick up enough on one watching of that video to figure out how to add that myself. A bit of Googling turned up this article [1] which includes that. [1] https://ieeexplore.ieee.org/iel7/5/6879517/06876131.pdf https://ieeexplore.ieee.org/iel7/5/6879517/06876131.pdf
- bob1029 5y agoI've been screwing around with a hand-crafted software rendering engine, and using a good old fashioned 4x4 matrix seems to give me everything I am looking for in this project. I do find the math and applications of quaternions to be elegant in theory, but there is a bit of a blackbox/theoretic veil that is harder to penetrate compared to a matrix representation (at least for me). The matrix also gives me all 3 things at once - rotation/scale/transform. Somewhere in my programmer brain this abstraction feels really nice to work with. Edit: This old & controversial article is what convinced me to stick with matrices for now: https://www.gamedev.net/tutorials/_/technical/math-and-physics/do-we-really-need-quaternions-r1199/ https://www.gamedev.net/tutorials/_/technical/math-and-physi...