Qooper on 24/2/2023 at 17:04
I know we have mathematicians in the crowd, but is there anyone who is familiar with geometric algebra?
The geometric algebra mosquito bit me and now I can't stop studying this stuff. It's cool how objects and operations are the same thing. A bivector is a rotation but also a plane. Also quaternions seem to come out of the math quite naturally.
I've got a few questions though. I'm trying to find the geometric algebra equivalent of a 4x4 transformation matrix that combines a translation, rotation and scaling. If I'm not completely mistaken, this can be done with a 3D multivector of grade 4. So for example:
Code:
T = a + (b*e1, c*e2, d*e3) + (e*e1^e2, f*e2^e3, g*e3^e1) + h*e1^e2^e3, where a, b, c, d, e, f, g and h are real numbers, and e1, e2 and e3 are the basis vectors.
Then, if I wanted to transform a 3D vector, I could just do Tv/T. So far correct, aye? And using the geometric product I can combine multivectors just like with matrices: T'=T1T2. But how do I get the x, y and z translation of a multivector? Or the rotation as euler angles?
Anyways, I'm not a mathematician, but I like graphics programming, and this stuff *IS* like it could nicely augment linear algebra.
demagogue on 25/2/2023 at 01:07
I haven't quite gotten rotations down yet, so that's my bottleneck in helping out here.
Well I'm going through this phase now too though. It's a weird bug to get.
At least for me, I think during the lock down period, I gravitated towards a subject where you can actually make progress towards something with a right answer, and I'm a visual thinker. So the geometric approach to linear algebra caught me.
All that said, I had a cool recognition recently I want to tell people about. There's always a lot of confusion in quantum mechanics, why do you square the wave function amplitude coefficients to get probability (i.e., Born's Rule), and what even is the wave function? There are a lot of tutorials trying to explain it, but they all do an awful job, and I haven't found any that give the simple geometric explanation where you can just see it. I'm almost upset with them all for not doing it like I think it could be done, visually intuitively.
So I spent some time just trying to figure it out for myself. Part of me wanted to write it out here, but it's gonna be way too long than is good for a thread, so I threw it (
https://chaopolis.substack.com/p/quick-visual-intuition-for-borns) here if you're interested in seeing it. I actually got excited about coming to this understanding because it's a question that had bothered me for so long, and the explanation isn't even all that complicated (once you have a little background knowledge; it might still seem complicated if it's your first QM rodeo.)
lowenz on 25/2/2023 at 11:52
Quote Posted by Qooper
but I like graphics programming, and this stuff
seems like it could nicely augment linear algebra.
SEEMS?
*IS* :D
geometric algebra is the core of computer graphics (before AI will redesign everything of what we know :p )
Qooper on 25/2/2023 at 18:09
Quote Posted by demagogue
I haven't quite gotten rotations down yet, so that's my bottleneck in helping out here.
But you know quaternions though? And how they interpolate smoother and are more efficient to compute vs Euler angles?
Quote:
So I spent some time just trying to figure it out for myself. Part of me wanted to write it out here, but it's gonna be way too long than is good for a thread, so I threw it (
https://chaopolis.substack.com/p/quick-visual-intuition-for-borns) here if you're interested in seeing it. I actually got excited about coming to this understanding because it's a question that had bothered me for so long, and the explanation isn't even all that complicated (once you have a little background knowledge; it might still seem complicated if it's your first QM rodeo.)
Thanks, I'll check it out. I'm not too well versed in the math of QM, but hopefully I can still follow along.
I'm using this stuff for 3D rendering, so I mostly split things into user side and computation. On the user side I use a vec3 for position, vec3 for rotation as Euler angles, and vec3 for scaling along each axis. On the computation side I previously used quaternions for rotations, which I converted to a 4x4 transformation matrix that contains all three of the aforementioned aspects. Now I'm trying to use multivectors to combine position and rotation.
If you've ever used Unity, the transform is those three fields at the top in the Inspector:
Inline Image:
https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fimages0.cnblogs.com%2Fblog2015%2F450977%2F201506%2F161928398571134.gif&f=1&nofb=1&ipt=3c86a5ed9233abb36254ab5d72fd0676c4cf9a57f2a57ac7c6aa57265c6cf27f&ipo=imagesQuote Posted by lowenz
SEEMS?
*IS* :D
I fixed my error :)
lowenz, how do you do transformations with GA?
demagogue on 25/2/2023 at 20:53
Quote Posted by Qooper
But you know quaternions though? And how they interpolate smoother and are more efficient to compute vs Euler angles?
Yeah, in principle. :D That's still a ways from practice.
My whole experience for this kind of stuff is following the dev threads for Dark Mod and sometimes trying to pretend I can help out. One of the big issues where coding rotations comes up is that the axis of rotation in id4 is world-centric, but but you often need object-centric axes. A common example is outside cellar doors opening at like 30 degree angles from the ground. FMs love cellar entrances. I think the even more common example is when you resize an object in the editor, it doesn't rescale the axis of rotation with it (unless they've fixed that since I read about it).
In those kinds of cases, short of changing the source code, to make them you just have to use a conversion factor from object to world coordinates for the axis and rotation. It's hard to make it perfectly on-axis and smooth to be realistic though.
Somebody actually made a thread not too long ago comparing three approaches, Euler angles, quaternions, and matrix rotations. Id4 uses Euler angle convention by default, but I think that thread concluded that matrix rotations were the way to go. I can't find it just now though. There are quite a few threads in the forum on coding rotations, but I don't know if they'd be any more helpful for you than digging through Stack Exchange posts.
Qooper on 26/2/2023 at 00:54
Does (
https://latexpad.clrnd.com.ar/#14bad9c74294f1dfd501d7f576752d77) this look okay to you guys?
Quote Posted by demagogue
One of the big issues where coding rotations comes up is that the axis of rotation in id4 is world-centric, but but you often need object-centric axes.
If I'm not mistaken, that sounds like idTech4 is missing object local transforms and pivot points?
Hit Deity on 26/2/2023 at 04:30
Quote Posted by Qooper
I know we have mathematicians in the crowd, but is there anyone who is familiar with geometric algebra?
The geometric algebra mosquito bit me and now I can't stop studying this stuff. It's cool how objects and operations are the same thing. A bivector is a rotation but also a plane. Also quaternions seem to come out of the math quite naturally.
I've got a few questions though. I'm trying to find the geometric algebra equivalent of a 4x4 transformation matrix that combines a translation, rotation and scaling. If I'm not completely mistaken, this can be done with a 3D multivector of grade 4.
I plugged this part into ChatGPT and got this back:
Quote:
Yes, you are correct that a 4x4 transformation matrix that combines translation, rotation, and scaling can be represented as a 3D multivector of grade 4 in geometric algebra. The 3D multivector of grade 4 is also known as the "translator" in geometric algebra.
To construct the translator, you can use the following formula:
T = 1 + t + (1/2)t^2 + (1/6)t^3 + s
where t is a 3D vector representing the translation, s is a scalar representing the scaling, and ^ represents the geometric product.
The terms 1, t, (1/2)t^2, and (1/6)t^3 represent the translation part of the transformation, while the scalar s represents the scaling part. The rotation part of the transformation is represented by the geometric product of the translator with a 3D multivector of grade 3, which is known as the "rotor" in geometric algebra.
To apply the transformation to a 3D vector v, you can use the following formula:
v' = Tvt
where v' is the transformed vector, v is the original vector, and the subscript t indicates that v is being transformed by the translator T.
Geometric algebra provides a powerful and elegant framework for representing and manipulating geometric transformations, making it a useful tool for computer graphics, robotics, and other applications that involve 3D geometry.
Plugging in the second part,
Quote:
Then, if I wanted to transform a 3D vector, I could just do Tv/T. So far correct, aye? And using the geometric product I can combine multivectors just like with matrices: T'=T1T2. But how do I get the x, y and z translation of a multivector? Or the rotation as euler angles?
I got this:
Quote:
Yes, you are correct that to transform a 3D vector v using the translator T, you can use the formula v' = Tvt/T. This formula applies the transformation to the vector v and then normalizes it to get a unit vector, which is equivalent to applying the rotation and scaling part of the transformation to the vector.
Regarding the combination of multivectors, you are also correct that you can use the geometric product to combine multivectors. For example, if you have two translators T1 and T2, you can combine them to get the resulting translator T' using the formula T' = T1T2.
To extract the x, y, and z translation components of a translator multivector, you can use the following formula:
t = (T - T^-1)/2
where T^-1 is the inverse of the translator T, and the subscript -1 represents the inverse of a multivector. The formula subtracts the inverse of the translator from the translator and then divides the result by 2 to extract the translation components. The translation components can be extracted as a 3D vector.
Regarding the rotation part of the transformation, you can extract the rotation as Euler angles using the following formula:
R = log(R)
where R is a 3D multivector representing the rotation part of the transformation, and log is the logarithm function in geometric algebra. The formula applies the logarithm function to the rotation multivector to extract the rotation as a 3D vector, which can be converted to Euler angles using standard formulas.
I've been playing around with ChatGPT today, trying to break, er I mean, test it, and I had to see what it could do with this problem.
Qooper on 26/2/2023 at 19:01
Math doesn't seem to be ChatGPT's strongest suite:
Quote:
To construct the translator, you can use the following formula:
T = 1 + t + (1/2)t^2 + (1/6)t^3 + s
where t is a 3D vector representing the translation, s is a scalar representing the scaling, and ^ represents the geometric product.
I'm pretty sure that's not the formula. For starters, the wedge product between a vector and a scalar is just an ordinary scalar-vector multiplication. Second, the wedge product is not the geometric product - it is a part of it.
The funny thing is if one glances though the text very quickly, it kinda _looks_ like geometric algebra on the surface with things like the wedge and the T^-1 and the log(R) etc.
I told ChatGPT to write a story in the style of mathematical notation (lately every thread seems to slowly turn into a ChatGPT laughathon :D), and it gave me this gem:
Quote:
Let I be an inventor who lives in Paris under the bridge B = {(x, y) | x, y ∈ ℝ} and works on his inventions in a makeshift lab at L = {(x, y) | x, y ∈ ℝ}. For months, I has been working on an invention Z ⊂ U, where U is the set of all possible inventions. However, I lacks the necessary resources to complete his work.
One day, an investor V offers to fund I's work in exchange for a share of the profits. Let F ∈ ℝ⁺ be the amount of funding provided by V. The terms of their agreement can be represented as:
(I, V) ∈ P(B, U, ℝ⁺)
P(B, U, ℝ⁺) = { (I, V) | ∃ F ∈ ℝ⁺, I(L, Z) ⊂ U, P = F * α(I(L, Z)) }
where α(I(L, Z)) represents the quality of the invention Z produced by I, and P represents the eventual profits split between I and V according to the amount of funding provided by V.
With the funding from V, I is able to complete Z to a high standard of quality α(I(L, Z)) = q ∈ ℝ⁺, where q is the maximum possible quality of Z. Therefore, the partnership between I and V yields a profit of P = F * q, which is split between them as agreed upon:
P/2 = F * α(I(L, Z))/2
The success of their partnership leads to I being able to continue his work and make more groundbreaking inventions, and V receiving a return on their investment. The partnership can be represented as a binary relation between the sets of inventors, investors, and funding, and the profits can be represented as a function of the quality of the invention and the amount of funding provided.
I love how the bridge is an integral part of the terms of their agreement :D
demagogue on 26/2/2023 at 22:12
Speaking of vector rotations, eigenchris, who has the best tutorials on tensors, et al, just dropped his video on rotations of spinors today. His tutorials have been so consistently great, it always feels like a big deal when a new one drops. If you want to study this stuff, I recommend going through (
https://www.youtube.com/@eigenchris/videos) his tutorials from the start or from wherever you are. He makes everything so visually intuitive.
He pays it off by walking through General Relativity. I wish he'd do the same for Quantum Mechanics, but it's not his home field. But just getting Spinors for now is okay. And he says he may get to QM some day.
Hit Deity on 1/3/2023 at 20:45
@Qooper: I agree. Even the simplest of problems confuses the hell out of it.
I posed the classic "If one car travels at 60 mph for 1 hour then another car starts off after it at 75 mph, how long will it take for the 2nd one to overtake the first?" I told it to ignore acceleration, etc . And it set it up ok, but then proceeded to tell me that the first car travels 300 miles and the second travels 60 miles. And this was AFTER it had correctly stated that both cars will have traveled the same distance in the end.
So yeah, it's pretty terrible at simple problems usually involving more than 2 variables.