Live data from Hacker News

Let's remove Quaternions from every 3D Engine

marctenbosch.com

81–90 of 184 posts

Re: Let's remove Quaternions from every 3D Engine

#81
post #31

Hmm, the word "interpolate" does not appear in the article. One of the main applications of quaternions in games is interpolating rotations. Does this representation interpolate well? Also, I've seen several articles trying to convince me that alternative transformation representations like these are better, but I haven't seen much code. Has anyone written a library using these concepts that could replace a tradition…

You can take the logarithm of a rotor in order to do interpolation. If you want a transformation represented by a rotor R to happen in N steps, you can apply R ^ (1/N) N times. The Nth root of R is exp(log(R)/N)

And if you don’t want to take the logarithm per se, you can bisect the rotation A by taking the sum of your rotor + 1, and then normalizing the result by dividing by the magnitude, (A + 1) / |A + 1|. Or if you have two rotors A and B, you can interpolate halfway between by taking (A + B) / |A + B|. This requires seven additions, four multiplications, one division, and one square root.

Re: Let's remove Quaternions from every 3D Engine

#82

Earlier quoted context omitted.

In my personal experience physicists are usually rather pragmatic about these things. Not many will support a "project of moving to geometric algebra" for its own sake, or the sake of perceived mathematical elegance - I know I wouldn't, even though I spent some time studying it just for fun. On the other hand, find a problem where geometric algebra gets you to a useful insight in a quicker or more natural way and few…

> On the other hand, find a problem where geometric algebra gets you to a useful insight in a quicker or more natural way and few will object to treating it in that language. I would argue that E&M and anything involving rotations (or Lorenzt boosts!) are two great examples where GA is miles ahead of anything other than differential forms but still has modest advantages of differential forms as well. The main advanta…

How does Geometric Algebra link into the 4-vector representation of E&M?

https://mitpress.mit.edu/books/collective-electrodynamics

Re: Let's remove Quaternions from every 3D Engine

#83

Earlier quoted context omitted.

Unit quaternions are isomorphic to rotors, so there’s no practical difference between the two. The difference is how you introduce the concept of 3d rotation: the “traditional” way is to introduce quaternions with i^2 = j^2 = k^2 = -1, and then do some handwaving to convince the reader that they are good for 3d rotations. The bivector formalism is more natural and needs no handwaving.

Thank you! I am really starting webgl, opengl study, and so I am hoping to start on the right footing. I was beginning those quaternion videos, but I think it will benefit me to look closely here too!

Make sure you understand the Rodriguez rotation formula first, then move onto quaternions and rotors. Whenever you become confused, just write out all the terms and you’ll get back to Rodriguez’s formula.

Re: Let's remove Quaternions from every 3D Engine

#84
post #65

Earlier quoted context omitted.

I think that last point really needs to start with a thorough reform of basic mathematical education (starting from undergrad calculus) to have any chance of real success. The present mish-mash of notations, however disjointed, lends itself very well to teaching people who don't know much beyond basic real analysis and differential equations. You can't just throw them in a GA-based E&M class without completely changi…

> You can't just throw them in a GA-based E&M class without completely changing the entire curriculum first. Preparing for the additional requirements of the lectures of the coming semester is whar the semester break is for.

Nah, you really want to start students learning the GA formalism in their linear algebra and vector calculus classes, if not in high school.

Especially important in high school is to dive into not only the “complex numbers” but also the “split complex numbers”.

Re: Let's remove Quaternions from every 3D Engine

#85

Earlier quoted context omitted.

Yes, anything you can do on quaternions you can do on rotors. (Updated the article) I have not seen a clean version of the code online but it is almost the same as for a quaternion.

Great post although it made me hungry for explanation what are the actual implementation differences between rotors and quaternions because I got the impression that we use exactly same real numbers to do exactly same things. We just imagine basis of this transformation space not as some 4 orthogonal vectors, just 3 orthogonal unit planes plus one real number for scaling. Those bivectors just explain (incredibly, ama…

99% of the time this is true.

Re: Let's remove Quaternions from every 3D Engine

#86

Earlier quoted context omitted.

Thank you! I am really starting webgl, opengl study, and so I am hoping to start on the right footing. I was beginning those quaternion videos, but I think it will benefit me to look closely here too!

Make sure you understand the Rodriguez rotation formula first, then move onto quaternions and rotors. Whenever you become confused, just write out all the terms and you’ll get back to Rodriguez’s formula.

Thank you! Will do

Re: Let's remove Quaternions from every 3D Engine

#87
post #39

Texts on GA seem to start out saying "we're going to replace vector analysis with something intuitive and natural and eloquent and..." and then immediately introduce the "geometric product", which is neither intuitive, eloquent, or, as far as I can tell, natural. Its properties are found via formula-wrangling, and the results you get from it seem to just magically work, rather than being intuitive. Bivectors in gener…

In my opinion, the problem is not the geometric product, but having three products (inner, outer and geometric). I have explained GA using a single product, and I think it is much clearer.

Of course, the inner and outer products are also very useful, but I introduce them only at the last stage, as some extra notation, not to help understand new concepts.

Re: Let's remove Quaternions from every 3D Engine

#88
post #31

Earlier quoted context omitted.

You can take the logarithm of a rotor in order to do interpolation. If you want a transformation represented by a rotor R to happen in N steps, you can apply R ^ (1/N) N times. The Nth root of R is exp(log(R)/N)

And if you don’t want to take the logarithm per se, you can bisect the rotation A by taking the sum of your rotor + 1, and then normalizing the result by dividing by the magnitude, (A + 1) / |A + 1|. Or if you have two rotors A and B, you can interpolate halfway between by taking (A + B) / |A + B|. This requires seven additions, four multiplications, one division, and one square root.

I would replace the last two operations by another multiplication and one reciprocal square root. There is extensive SIMD support for very fast approximations, and getting better in newer chips.

Re: Let's remove Quaternions from every 3D Engine

#89
post #39

Texts on GA seem to start out saying "we're going to replace vector analysis with something intuitive and natural and eloquent and..." and then immediately introduce the "geometric product", which is neither intuitive, eloquent, or, as far as I can tell, natural. Its properties are found via formula-wrangling, and the results you get from it seem to just magically work, rather than being intuitive. Bivectors in gener…

From the sounds of it, I think you'd be much more happy working with differential forms! Differential forms use only the wedge product and a duality mapping known as the hodge dual (It's the GA equivalent of multiplying by the psuedoscalar). Differnetial forms easily supply 90% of the nice things in GA, so if you're unhappy with the geomtric product, I'd say that differnetial forms are perfect. Geometric algebra will…

I learned about differential forms in my physics degree, and then later discovered that the exterior algebra made a lot more sense if you introduced it separately. Basically it seems like the exterior algebra is useful in many settings, and differential-forms are just one rather confusing application of it. My current opinion is that exterior algebra should, someday, be taught first (around the time of linear algebra), and then later extended to differential forms when derivatives and manifolds get involved.

I agree that the Hodge Dual is easily the worst part of exterior algebra. But you can treat the inner product as more fundamental, via *a ∧ b = i. Either can essentially be constructed from the other (iirc).

Re: Let's remove Quaternions from every 3D Engine

#90
post #39

Texts on GA seem to start out saying "we're going to replace vector analysis with something intuitive and natural and eloquent and..." and then immediately introduce the "geometric product", which is neither intuitive, eloquent, or, as far as I can tell, natural. Its properties are found via formula-wrangling, and the results you get from it seem to just magically work, rather than being intuitive. Bivectors in gener…

The geometric product is super useful and important! (As well as much nicer to work with when doing algebraic manipulation.)

In particular, it is what lets you take products, inverses and quotients (assuming the denominator is non-null) of arbitrary vectors.

> surprisingly hard to compute

Hm? No it isn’t....

Several times in the last few years I have done several pages of complicated calculations in terms of coordinates or matrices, where the intermediate steps were basically an indecipherable mess of symbols, and then sat down, really thought about what I was doing for a while, and re-written it using GA language and ended up simplifying my work down to a few lines of simple algebraic manipulations, where I could typically then give a nice geometrical interpretation to each step.

If you want to compute the geometric product using concrete numbers in terms of a basis, then it is straightforward to write the code (or work through by hand).

What is hard is not the geometric product. What is hard is geometry! There is a lot of depth and subtlety, and it takes years to really learn your way around. That is not the fault of the language though; there is a certain amount of irreducible complexity involved.

Personally I would love to get some people together and try to write a high-school-accessible geometry / vector algebra book using GA language. It would be a few years of hard work, because figuring out the right order for the curriculum, the right types of problems to build intuition, which tools to include or leave out of an introductory book, how to best show the work for a whole collection of worked examples (ideally with some interactive computer diagrams), and so on.

Post reply on HN