Let's remove Quaternions from every 3D Engine: Intro to Rotors from Geometric Algebra

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
let's remove quaternions from every three engine to represent 3d rotations graphics programmers use quaternions however quaternions are taught at face value we just accept their odd multiplication tables and other arcane definitions and use them as black boxes that rotate vectors in the ways we want why does AI square called J Square equal K squared equals negative 1 and I times J equals K why do we take a vector and upgrade it to an imaginary vector in order to transform it personally I've always found it important to actually understand the things I'm using I remember learning about cross products and quaternions and being confused about why they worked this way but nobody talked about it later on I learned about geometric algebra and suddenly I could see that the questions I had were legitimate and everything became so much clearer in geometric algebra there is a way to represent rotations called a rotor that generalizes quaternions in 3d and complex numbers in 2d and even works in any number of dimensions 3d rotors are in a sense the true form of quaternions or in other words quaternions are an obfuscated version of rotors they are equivalent in that they have the same number of components their API is the same they are as efficient they are good for interpolation and avoiding gimbal lock et cetera in fact they are isomorphic so it is possible to do some after turn a rotor engine quaternion but doing so makes them less general and less intuitive and loses extra capabilities but instead of defining quaternions out of nowhere and trying to explain how they work or attractively it is possible to explain rotors almost entirely from scratch this obviously takes more time but I find it is very much worth it because it makes them much easier to understand for example core Trinian's are introduced as this mysterious four dimensional object but why introduce a fourth dimension of space to visualize a 3d concept like contrast 3d orders do not require the use of a fourth dimension of space in order to be visualized trying to visualize quaternions as operating in 4d just to explain 3d rotations is a bit like trying to understand planetary motion from an earth centric perspective which becomes overly complex because you are looking at it from the wrong view point it would be great if we could start phasing out the use and teaching of car engines and replace them of rotors change is simple and the code remains almost the same but the understanding grows a lot as a sidenote Jew metric algebra contains more than just rotors and is a very useful tool to have in one's toolbox by the way there is an Associated article to this video if you prefer it also contains every interactive diagram that will be shown here in 3d we usually think of rotations as happening around an axis like a wheel turning around its axle but instead of thinking about the axle a more correct way is to think about the plane that the reel lies on perpendicular to the axle this is because if we split a vector into two pieces one lying inside the plane and one lying outside the plane the rotation rotates the inside part while keeping the outside part the same in 2d there is only a single plane to rotate in there is no outside part therefore considering rotations to happen around the third axis perpendicular to the 2d plane is technically incorrect since we shouldn't need to introduce another dimension to perform rotations in addition when thinking about rotation around an axis the sense of rotation is undefined and so needs to be defined by convention via the so-called right hand rule however if we think about rotations as happening inside planes the sense of rotation is clear rotation in the XY plane means a rotation that takes the vector X to the vector Y inside the plane and form together rotation in the Y X plane is the opposite rotation it takes the vector Y to the vector X to compute the axis of rotation to rotate one vector a to another vector B we take the cross product of the two vectors to get a vector that is perpendicular to both but why leave the plane since the rotation is fundamentally a 2d thing instead we take what is called the outer product of the two vectors building a new element called a by vector that represents the plane the two vectors formed together if the cross product creates the normal vector to a plane the outer product creates the plane itself taking the normal to the plane is extraneous the by vector B can be represented as the parallelogram built from the vectors a and B in the plane they form together the idea of a buy vector might seem strange at first but they are pretty much as fundamental as vectors if a vector is like a line then the buy vector is like a plane by vectors have components just like vectors but they are defined in terms of basis planes instead of basis lines like vectors if the orthogonal basis planes are XY X Z and Y Z but first let's look at the simpler 2d case in 2d there's only one plane in the XY plane so 2d by vector only has one component 4 by vector built from vectors a and B this number is equal to the signed area of the parallelogram the two vectors form together you can see that by changing the angle between the vectors the area of the parallelogram changes according to the sine of the angle you if the vectors are the same or if they are parallel they don't form a proper plane and the result is zero the simple property defines what a buy vector is by looking at the sum of two vectors we can see that this property implies the following we just need to expand the product and delete the terms that Square to zero a outter b is equal to minus b outer a just like the sense of a rotation matters the order of the arguments to the outer product matters swapping arguments changes the sign of the results this is called anti-symmetric here the sign is representing using the color which changes from blue to green the sign changes whenever the rotation from A to B goes from being clockwise to being an anti-clockwise that is if it matches the X to Y direction or the Y to X direction the properties of the outer product are suited to capture the properties of planes and rotations the vectors obviously don't have to be unit lengths and here the restriction is removed the signed area of the parallelogram is proportional to the lengths or both vectors so for example doubling the length of one vector doubles the area we can get the actual value by plugging in the vectors in component form we just need to expand the product and delete the terms that Square to zero you just like the coordinates of a vector V can be thought of as the projections of the vector onto the three orthogonal basis axes coordinates of a by vector B can be thought of as the projection of the small plane onto the three orthogonal basis planes the projections of the vector are the length of that vector along each basis vector while the projection of the by vector are the areas of the plane on each basis plane you can play with this diagram in the linked article using the same method as before values of the components look a lot like the XY component from the 2d case but applied to all three planes in 3d the definition of the other product is very similar to that of the cross-product in fact in 3d a vector that comes from a cross product such as a normal vector will have three components which are equal to the components of the BI vector the numbers are the same but the basis is different the by vector definition makes sense geometrically instead of appearing out of thin air I remember thinking when I was learning the cross product why the hell does it return a vector that has length equal to the area of the parallelogram formed by the two vectors that feels so arbitrary in 3d a by vectors three coordinates one per plane vectors also have three coordinates one per axis each plane is perpendicular to one axis this is a coincidence that only happens in three dimensions and it is why historically we have been confusing by vectors or vectors here's an example you might have seen how normal vectors transform differently than regular vectors using the inverse transpose of the matrix instead of the matrix itself that's because they are not really vectors but actually by vectors which we have type-cast two vectors in physics there's a hack of an axial vector which has been introduced to differentiate vectors that come from cross-product from regular vectors by a vector is the actual type of the object and it should be thought of and manipulated as such we can keep taking the outer product to build not just oriented to the areas but oriented 3d volumes as well a tri vector T can be built by taking the outer product twice in 3d it stops there just like in 3d there is only one plane which fills all 2d space in 3d there's only one volume which fills all of 3d space in 3d a tri vector only has one basis component equal to the volume of the parallelepiped generated by the three vectors the triple other product is a better version of the scalar triple product because it only involves one kind of operation returns the correct type volume instead of scaler and works in any number of dimensions the geometric product denoted without a symbol is another operation we can do on vectors the geometric product is defined to have nice properties like associativity and so the vectors have inverses that is a times a inverse equals one where one is just a number one the goal is to be able to multiply vectors together so that just like from matrices multiplication corresponds to geometric operations to define the product first note that it is possible to split a product or any function that takes two arguments into the sum of a part that does not change if we swap the arguments and one that does change the first term does not depend on the order of the arguments a and B anymore it is called the symmetric part while the second term changes sign when the arguments are swapped it is called the anti-symmetric part the dot product of two vectors is symmetric and the measure of distance so it sounds useful geometrically to set it equal to the symmetric part similarly the outer product of two vectors is an anti-symmetric so it sounds useful geometrically to set it equal to the anti-symmetric part in addition the dot product contains the cosine of the angle between the two vectors while the outer product contains the sine of the angle together they fully describe the angle between the two vectors as well as the plane they form so the geometric product is the following it is strange because multiplying two vectors together gives the sum of two different things a scalar and a by vector however this is similar to how a complex number is the sum of a scalar and an imaginary number so you might be used to it already here the BI vector part corresponds to the imaginary part of the complex number except it's not imaginary is just a bi vector which we have a concrete picture of basically by multiplying two vectors together we compute useful properties about them which has a length for their projection onto each other or the cosine of the angle and the plane they form together and the sine of the angle the we keep these bundle together via the plus sign the geometric product also gives these property bundles operations that can be applied to them and these operations have geometric interpretations for example rotating and reflecting vectors the multiplication table helps make this product more concrete let's see what happens if we take products of the basis vectors for any basis vectors such as the x axis the result is 1 for any pair of basis vectors such as the x and y-axes the result is just the by vector they form together this gives the following table it's basically trivial unlike the quaternion table for example if we have a unit vector a 2v we can reflect v by the and included a this is done the usual way we decomposed V into a part perpendicular to the plane and a part parallel to the plane then to reflect the vector flip the perpendicular part while keeping the parallel part unchanged you at this point we can replace the dot product geometric product version to get the following for this step the geometric product of a wave itself is just a dot product since the exterior product is zero this is saying the exact same thing but ended notation using a simple product notation instead of a formula to encode the fundamental operations such as a reflection is going to prove very useful it turns out that if we apply two successive reflections to V using vector a followed by vector B we get a rotation by twice the angle between the vectors a and B you can play with this diagram in the linked article you in the 3d case the vector V can be split into two different parts one lying inside the plane defined by a and B and one lying outside the plane as seen here when the vector gets reflected by each plane its outside part stays the same you so for the inside part we are back to the 2d case and it just gets rotated by twice the angle in terms of the geometric product that flexions simply correspond to the following you we call a be a rotor because multiplying by a B on both sides of a vector performs a rotation applying a rotor a B to both sides of a vector rotates this vector in the plane of vectors a and B by twice the angle between a and B and that's all there is to it we can notice that 3d rotors look a lot like quaternions however as we have seen 3d rotors our 3d concept that does not require the use of 40 double rotations or stereographic projections to visualize trying to visualize quaternions as operating in 4d just to explain 3d rotations is a bit like trying to understand planetary motion from an earth centric perspective that is it will be overly complex because you are looking at it from the wrong viewpoint as we have seen representing rotations as operating inside planes instead of around vectors helps a lot for example the basis by vectors square root of negative 1 just like the basis quaternions you multiplying two by vectors together gives aford by vector but this is basically trivial and we don't have to remember how I times J equals K these properties are a consequence of the geometric product instead of appearing out of thin air and that's it like I said if you want to play with any of the diagrams shown in this video or if you want to read a written version you can go to the following link
Info
Channel: Marc ten Bosch
Views: 145,327
Rating: undefined out of 5
Keywords:
Id: Idlv83CxP-8
Channel Id: undefined
Length: 16min 47sec (1007 seconds)
Published: Thu Jan 30 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.