Quarternions allow you to specify the axis of rotation. This is very advantageous for some situations. Like rotating a virtual camera to a point at a specific vector, cross product of camera direction and specific vector is axis of rotation, dot product will give you the rotation angle. Euler rotations are good for specifying an objects orientation. I learned about Euler rotations in college and did not learn about quarternions until I was deep into my career. I think quarternions are useful enough that they should be taught in schools, they fit nicely with dot and cross product.
I appreciate your perspective and good examples of use cases for Euler and quaternions. It would likely benefit many to learn about quaternions earlier. Hopefully more exposure to quaternions finds its way to those who need it.
This was the video that finally makes me "get it" for gimbal locks. Maybe its just the fact that I have been watching several videos of gimbal lock but walking away with a half-ass understanding of it. I think the way you put it - the gimbals have to make a wierd detour to get to an angle which requires rotation in that "lost" degree of freedom and the fact that when the gimbal lock occurs any rotation applied to that axis goes to the "stable platform" hence losing the priced orientation it contained is what made me add it up.
I am glad this video could be supportive in growing your understanding of gimbal locks! That detour concept can be tricky to comprehend at first, in combination with that "lost" degree of freedom. I appreciate hearing your experience, thank you for sharing it! :)
Euler angles are _compositions_ of 3 basis rotations. Quaternions are _mixtures_ (technically "linear combinations") of the same 3 basis rotations, but specifically 180° rotations around each axis, plus a fourth "0°" rotation term. Also important to mention: Quaternions are _rotations_ *not* *_orientations._* For every _orientation,_ there are two different _rotations_ that bring you to that orientation. These are often called "clockwise" and "counterclockwise," and in quaternions, the two different rotations have two different quaternions, which are also the negatives of each other. Interpolating quaternions only takes the shortest path with _one_ of these rotations, but not the other, which instead does take the long way around. Interpolating a 360° rotation is still hard because every possible axis will eventually get you to the right place. "It represents something called 'the scalar value'" Which is a really fancy way of saying "doing absolutely nothing." It is the 0° rotation I mentioned earlier. Regarding the world axis, that's exactly what quaternions do best. The world axis is a line which, when interpreted as a quaternion directly, is a 180° rotation. Mix in some "do nothing" in different quantities and you can get any rotation from -360° to 360° around said axis. (Be careful, vanilla quaternions can only rotate around the origin of the space you're using... or at least, _vanilla_ quaternions can.)
I like how you phrased Euler angles as compositions, and quaternions as mixtures. That seems like a helpful way to think of how the parts are used to form the wholes. In the video I state that any set of Euler or quaternion values "represents a single orientation". Perhaps "results in a single orientation" may be perceived as more accurate when considering how Euler and quaternions can also be viewed for their rotational values. On the topic of interpolation, I could have better specified that spherical linear interpolation (SLERP) with quaternions is what I was referring too. And after reviewing your comment it does appear that slerp algorithms for quaternions can produce either the shortest or longest path. It appears that this can be accomplished by negating one end of the values. I have been able to reproduce this, specifically in Blender. By manually negating a keyframe's quaternion values the interpolated rotation takes the longest route; However, for quaternions this only appears to work up to 359.99 degrees. Perhaps this is a limitation held by some 3D applications, or the algorithm itself. Thank you for sharing your experience!
@@classoutside I'm pretty sure the limit of 360° is inherent. Quaternions themselves can represent any rotation around the origin with an angle between -360° and 360° exclusive on both ends. (For rotations _no_ around the origin, there is a small extension that's possible.) At 360°, it's caught at the exact halfway point not just between both directions, but _all possible_ directions. Being 360° though, it should be understandable that wanting to perform a 360° rotation isn't terribly common. In case you're wondering, the quaternion for a 360° rotation is -1, which you might notice is lacking any information about the axis it was around. It's possible that 360° = -1 might look familiar to some, and not in a good way. No, it's not a complete coincidence that it looks like a spin-½ particle from quantum mechanics. There are however very good reasons for both instances of this phenomenon that _aren't_ inherently quantum.
There _is_ a way to visualize quaternions much like Euler angles. With Euler angles, the three values form a vector which points along the axis of rotation. The length of this vector is the amount of rotation. It's much the same with quaternions: the XYZ components form a vector which points along the axis of rotation, but now it's the _ratio_ of the length of this vector to the W component which determines the amount of rotation.
I agree, it is possible to provide visualizations that are meant to represent quaternions. I appreciate your helpful explanation. Your description appears in line with my understanding and what I have seen in visualization attempts so far. The challenge I face is I have not yet come across a visual example that I subjectively consider simple to comprehend, without some prerequisite knowledge or explanation of the math involved in the process. Thank you for providing your perspective and input on this!🙂
Technically, visualizing the angle as the length is basically visualizing the _logarithm_ of the quaternion. Taking the exponential of that converts the magnitude into a mixture of 180° rotation around the axis in question and 0° rotation.
@@angeldude101 That doesn't make much sense. The magnitude of a quaternion is always 1 because pure rotations are always unit quaternions, so they always have a length of 1. What @APaleDot said is also wrong. The 3 angles of a set of euler angles can be written as a vector, but that vector does not represent the rotation axis. This should be obvious from the fact that the same numerical representation (say 10,50,30) results in a completely different rotation depending on the used rotation order. There are 6 different conventions that are possible for euler angles. However it's true that a quaternion is simply a single rotation axis and the angle around that axis. You can easily construct a quaternion that rotates "D" degree around an arbitrary vector / axis V. First that axis vector has to be normalized, so has to have a length of 1. To create a quaternion out of those two pieces of information you just have to do: x = V.x * sin(D/2) y = V.y * sin(D/2) z = V.z * sin(D/2) w = cos(D/2) That's all. That's your quaternion that rotates D degrees around the axis V. Unity and some other software uses an unusual notation for quaternions as the normal notation is (a + bi + cj + dk). What Unity does is essentially (w + xi + yj + zk) The actual math is also quite simple but due to the number of elements will get quite convoluted. As you may know, in order to rotate a vector by a quaternion you have to do a "sandwich" multiplication. So you have to do q*v*q^-1. Here "q^-1" is just the "complex conjugate" of q. In the conjugate all the complex arguments are inverted. So q^-1 = (w - xi - yj - zk). The actual multiplication is pretty straight forward. Though you have to apply the multiplication rules for the complex identities i² = j² = k² = ijk = -1. The important part is the "ijk" because quaternion multiplication is not commutative. So the order of the multiplication matters. From those basic rules you can simply deduce: i*j = k j*i = -k j*k = i k*j = -i k*i = j i*k = -j With those you just multiply the parenthesis. Multiplying two quaternions together results in 16 terms (4 * 4) but after applying the above mentioned rules they reduce back to just 4 terms. Again one scaler and the 3 complex bases i, j and k. A unit quaternion can directly be transformed into a 3x3 rotation matrix since all members of the quaternion just contains the spatial orientation as well as sine and cosine values of the angle. The reason for the sandwich multiplication is directly tied to the fact that we only use half the angle in the sin / cos. That's because we essentially rotate the vector twice. The first rotation however rotates the vector into 4d space. The second rotation essentially brings it back into 3d space. If you want a concise explanation of quaternions, I can highly recommend the numberphile video on quaternions. For more details on how and why we need to apply the double rotation, watch the 3b1b videos on quaternions. An important point to note is that in 3d space it's actually possible to get from any orientation in space to any other rotation in space by just rotating around a single axis by a certain angle. Because a quaternion represents exactly this axis / angle construct, it can be used to go from any orientation to any other orientation. The concept of absolute orientation doesn't really exist, Any object has it's identity orientation which is just the way it was setup. So any other orientation can be seen as a relative rotation from that initial pose.
@@Bunny99s I actually follow a different convention for Quaternions, calling the basis Quaternions 1, ŷẑ, ẑx̂, and x̂ŷ, rather than "i, j, and k". A word of warning though, the basis as I've laid it out here actually has (ŷẑ)(ẑx̂) = -(x̂ŷ), and (ŷẑ)(ẑx̂)(x̂ŷ) = 1, rather than -1. You can however replace each basis element with a _sinister_ counterpart to restore the arbitrary identity of "ijk = -1". (Fun fact: "sinister" means "left-handed".) In fact, there are 48 possible quaternion bases (if you consider order to be important; otherwise it's only 8), only some of which satisfy ijk = -1, though all of them satisfy i² = j² = k² = -1. Why is each basis element written as two parts? What does it mean for x̂ to exist in its own in this context? I'm quite glad you asked (or not so glad, if you actually didn't ask). The answer is that x̂ in this system is _not_ an arrow, but rather a _mirror;_ specifically the x = 0 mirror. Multiplication is composition, and a mirror composed with itself being you back to where you started, so x̂² = 1. x̂ŷ is just a multiplication between x̂ and ŷ; a composition between two orthogonal mirrors, resulting a rotation by 180° around their intersection x = y = 0 (more commonly called "the z-axis", regardless of whether or not the problem is in 3D). To undo a rotation, you need to undo each reflection in the opposite order they were composed. (x̂ŷ)⁻¹ = (ŷ⁻¹)(x̂⁻¹) = (since x̂² = ŷ² = 1) ŷx̂ = -x̂ŷ. If the rotation isn't normalized, then you have to divide by the squared magnitude, which in some contexts may be cheaper than multiplying by an inverse square root. The sandwich product is simply composing a rotation (or other transformation) with some object (represented as a transformation itself), before undoing the first transformation: ABA⁻¹, or A⁻¹BA depending on your convention; whether you compose from right to left, or from left to write. I don't know what you mean by what I said being wrong. Quaternions being normalized is nothing more than a convention to make taking the inverse simpler. When taking the exponential of a non-normalized quaternion with no scalar part, it converts it into a normalized quaternion whose rotation covers a sector of the unit circle whose area is equal to the magnitude of the input. The logarithm simply does this in reverse: converting a quaternion into a different quaternion around the same axis whose magnitude of its non-scalar part is the area covered by the rotation while its scalar part is the logarithm of its total magnitude. Said magnitude is usually 1, so the logarithm of that, and by extension the scalar part of the output, is usually 0. exp(a + B) = exp(a)exp(B) = exp(a)(cos(|B|) + Bsinc(|B|)). Yes, that is the sinc(x) = sin(x)/x function. It's easier to write than normalizing B. For more information on this approach to Quaternions, check out A Visual Guide to Quaternions and Dual Quaternions, presented by Hamish Todd at the Math and Game Development Summit.
Having known quite a bit on that subject, math and Blender wise, I saw "Class Outside" under the most human thumbnail I've looked at in days; Surprised this was a Blender/Graphics tutory, but the overall atmosphere of the video was entraping and calming. You sir, have a great mind; stay focused!
Quaternions not caring about order is just wrong. pq =/= qp in that skew field. Just take (0, 1, 0, 0) and (0, 0, 1, 0) with the respective i, j and k values. It is not the same. You also did not touch upon the double cover properties of Quaternions. Thats why you have Angle/2 in the formulars concerning them.
That’s clearly not what they meant. They meant that, for example, 3/5•i+4/5•j is the same as 4/5•j+3/5•i; each one is a single number (transformation). In the video they were clearly talking about the “parts” of a rotation around each axis. And quaternion don’t split the rotation into parts, so their components do not need to be in any particular order.
I agree with you @fullfungo4476. I was referring to the order of components themselves. With Euler, XYZ will not necessarily produce the same result as ZYX, the order the values are represented matters. With Quaternions, you regularly operate in the order w i j k and do not need to be concerned about choosing a particular sequence. I appreciate you mentioning this @friedrichfreigeist3292, perhaps I could have made this more clear in the video. Further, by double cover i believe you are referring to the quality that each rotation can be represented in two ways. For example (w, i, j, k) as (0.1, 0.2, 0.3, 0.4) would appear the same as (-0.1, -0.2, -0.3, -0.4). I believe this is an important quality of quaternions. I believe this was left out of the video to retain focus on the key functional and distinguishing factors that I consider separate Euler and Quaternions when using 3D software.
for almost all rotations, euler rotation will not return the smallest possible angle. for small angles, quaternions suffer a too big precision-loss. matrix of axis angle rotation is identical to quaternions, but axis-angle-forms needs more memory and multiplications, usually not worth the gained precision, unless you do less than 2 rotations in a chain-sequence and precision really matters. the second life wiki has a function, that reasonably efficiently first calculates the angle, and then only does euler-rotation if the angle is small enough so that precision of the result matters more than rotating around a single axis.
I appreciate hearing your input. Taking the shortest path, or smallest possible angle, when rotating is often found when using spherical linear interpolation (SLERP) which is more common with quaternions, not euler rotation. As precision needs grow, it can be important to ensure calculations take those needs into account. I believe for 3D art and animation quaternions or euler values may be precise enough for most applications. I would have to research further to identify where either begins to be less precise. Computational efficiency can be very important. I was not aware of the second life function, thank you for sharing.
(note: I'm not a mathematician and I don't understand quaternions, the following is based purely on my experience as a game dev) Gimbal lock doesn't actually happen tho. If you stop thinking about gimbals, you can rotate an object according to euler angels at any given time in both absolute and local space Gimbal lock would only occur if you rotated a world axis with the rotation. Which doesn't actually happen. You either don't rotate any dimensions (absolute space) or you rotate all dimensions (local space)
I believe it is true that often in general rotations in 3D software like Blender or game engines may not visually experience gimbal lock. It is common for the code of this software to work with quaternion values even if visually the rotations are represented with X, Y, Z Euler. I do believe there are times where the affects of gimbal lock may be experienced when using 3D software. For instance, a script to programmatically rotate an object may directly affect the rotation with Euler values, rather than with quaternions. Another example would be in blender, if part of an animation is indicated to rotate around an axis, you may see other values begin to change unexpectedly as the animation plays. This may not visually appear similar to gimbal lock because the software is attempting to compensate for it; However, the result of unexpected XYZ values changing is an effect of the gimbal lock concept.
How many dimensions between the 3'rd and 4'th Floors, in this "If Zero/Then One" edifice.... I have a Tree House at 3.5 the Swiss Family Robinson would envy!
I wrote code for a 6DOF platform. Not only does the order make a difference but the direction of rotation must be defined. You can use the left hand or right hand rule. So there are many ways of moving the 6DOF platform. Rarely would two people get the order and directions the same. This was a problem because a flight simulator would down load x,y,z, yaw, pitch and roll but often the 6DOF would move as the customer thought it should. I finally decided to use the NASA's Glen Research centers standard and told people to use that. I need to figure out quaternions but the 6DOF platform doesn't make big angle changes.
Thank you for sharing your personal, hands-on, experience solving problems with concepts in this field. It sounds like it can be challenging when customer expectations do not initially align with common or planned for results, and standardization can help in these situations. I appreciate your input!
Just learned I lean to the Quatereulerions. "Ka-ter-oil-ler-ons" ... Alright..........I'm re-naming my new team: "3.5'ers" ... We took a left at Albuquerque!
Great video and explanation of gimbal lock. Though I think you could have spent more time on at least giving a brief explanation of what the four quaternion numbers represent / relate to (i.e. rotation axis and angle), even if you avoid the math or attempts at 4D visualization.
The amount of 180° rotation around the x-axis, the amount of 180° rotation around the y-axis, the amount of 180° around the z-axis, and the amount of 0° rotation around no axis. These four basis rotations can be mixed together in varying proportions to get any rotation around any 3D axis through the origin by any angle between -360° and 360°.
@@angeldude101 Yup. I'm more of a math guy, but friends in game dev say it's one of the more confusing topics they can never get satisfying answers to.
@@tedsheridan8725 Of course it's confusing when all you're taught is that it works and never why it works. When you actually understand the math, it all makes _so_ much more sense. Even the angle doubling feels inevitable to me now rather than a bizarre artifact that needs to be dealt with.
@@angeldude101 It must be quite hard for non-math people to wrap their heads around the details - trying to learn complex numbers AND 4D at the same time is bonkers. The "mixture of rotations" model is easier to understand, you just have to get used to the quirks. I started a math channel that will among other things explore 4D shapes - there will definitely be a quaternion video at some point.
Thank you for your compliment and suggestion. I agree, there may be value in providing some more information about what the values represent, even without sinking too deep into the math. If I get to iterate on this video some day, I intend to use this feedback to make it even better!
Orientation and direction are not the same thing. The fact that 3D orientations are representable with 3 Euler angles is just a coincidence. In 2D you only need one angle, and in 4D, you need six. In general, you need N coordinates to represent an N dimensional point, and (N^2+N)/2 angles (or bivectors) to represent an arbitrary rotation.
Orientation and direction may be known to have distinctions. I appreciate you pointing this out. The term orientation used in the video is meant to describe the rotation of an object relative to some reference position. In some of the graphics an arrow is imposed on an object to provide an arbitrary 'face' to better visualize how the object moves during the animation. I believe direction is commonly used in reference to the specific way something moved over time. I have also heard it used to represent the area with which something is pointing towards, whether or not that something is mobile. The underlying math behind 4D and higher rotations appears interesting.
Ah, so I'm not the only one here familiar with the Geometric Algebra approach to quaternions. Also while any given dimension has N choose 2 distinct basis axes, each dimension has a total of 2^(N-1) components for a full rotation. This is 2 when N = 2, just like a Complex number, 4 when N = 3, just like a quaternion, and 8 when N = 4, which is actually not like an octonion, but rather is more like a dual-quaternion.
well actually, normalized quaternions may be used to represent spacetime and relativistic calculations and transforms between reference-frames, where w then is time of spacetime. But this is usually not a good way to do those calculations, almost certainly too slow AND too low precision in the needed context, compared to simpler functions that calculate the same, without relying on quaternions or complex numbers.
You can pronounce him as Ey-ler, Эйлер in Russian. Euler lived in Russian Empire, published in Russian, and that's how he was referened to and self-referencing for years.
2:36 perfect describe of me after heard that, I has to track back and still can't stand that sentence😂 . Anyway great video is solve lot of question in my head.
Haha! Yes, 2:36 described me at one point too! In Euler, order matters, so X=90, Y=90, and Z=90 may output a different result when the rotations go in the order: 90 degrees on the X-axis, 90 degrees on the Y-axis, and 90 degrees on the Z-axis, compared to the result we get when the order rotates along the Y-axis first, then the X-axis, and finally the Z-axis. I try to visually display this between 2:45 and 3:33. I appreciate your compliment, and I am glad this video could help solve some of your questions :)
When animating in unreal you may be able to mark keyframes agnostic of rotation type (Quaternion vs Euler) and instead rotate around the world axis with other controls. I would recommend trying this first and monitoring the output. If you were to use Quaternion values to represent the keyframes in the rotation, you may need to use 2-3 keyframes. While under some circumstances it can be argued that Quaternions can represent a 360 degree range of values, it may not be able to accurately represent a desired angle taken to traverse from 0 to 360 to perform a full rotation. I hope this helps.
Quaternions didn't make sense to me until I learned about "Geometric Algebra", Hestenes, etc. They are very simple after seeing it from that point of view. Thinking of them as an unvisualizable 4D object isn't helpful.
I appreciate your feedback and resources that may help others interested in learning more about quaternions. While in the context of 3D software I don't believe it's necessary to visualize quaternions in order to apply them in a useful way, I would encourage those looking to understand more of the detail behind quaternions to continue seeking visual aids for this topic until they find what is right for them.
To make the backflip with a Quaternion, why couldn't you specify the 180 degree angle to rotate to then again back to 0, instead of the way you did it with two points through which the quaternion rotated through, for the dog on a skateboard backflip?
Spherical linear interpolation (SLERP) is usually how the paths between two quaternion rotations are determined in 3D software. For SLERP this takes the shortest path from one rotation to another, which will always be 180 degrees or less. While performing 3 separate rotations all below 180 degrees is adequate, there is potential to perform an animation like the backflip with only two 180 degree rotations. To perform it this way does require understanding a bit more about quaternions. In quaternions any 1 rotation has at least two ways to represent it. The rotation represented by (0.1, 0.2, 0.3, 0.4) should be identical to the rotation represented by the negative equivalent (-0.1, -0.2, -0.3, -0.4). What is different is the direction rotated to achieve these new orientations. Since any orientation is represented by two values, 180 degrees along the x-axis may be represented by either (0,1,0,0) or (0,-1,0,0). While both of these will end in the same position, one will reflect a backflip, and the other will look more like a front flip. While it is possible to perform a backflip or frontflip with 180 degree rotations and quaternions, keeping rotations below 180 degrees may come with fewer challenges when animating.
Numbers can be very useful in conveying concepts. With this video, my intention was to provide information about the conceptual differences of Euler and Quaternions, without entering into the underlying mathematics of them. Perhaps some day i will have another video that explores more into this topic. Thank you for your input, and sharing your experience!
If the tools we build, like spaceships, are chosen to use gimbal-like mechanisms, they too may be affected by gimbal lock. An object floating freely, like a spaceship, with forces applied to it, or mechanisms not constrained to gimbal-locking, will be free to rotate in all directions. Thank you for sharing this real world example!
The Rodrigues' formula and axis, angle representation may have benefits depending on how they are being applied. In this video my intent was to focus on Euler and Quaternion representations due to their adoption in popular 3D software tools. I appreciate your call out, and sharing this additional way to handle rotations.
Directional Cosine Matrices seem like an interesting solution to the 90 degree problem. I wonder how their implementations may be found in common 3D software programs. Thank you for sharing!
Euler angles do seem to come with many complications. The fact that quaternions have at least 2 ways to represent any single 3D rotation does stand out!
Geniua marketing to get the island sold. I wonder which politician has a stake in the sale. They will let it carry on and someine else will buy it to maje a stand.
@@classoutside sometimes when I watch a video and comment it posts the comment on the previous video lol it's a problem with the TH-cam app only happens on the phone.
Thank you for sharing. Effectively communicating concepts with others can be challenging. Pronunciation rules can be relaxed in some settings and still lead to effectively discussing the same topics. I have met some people who find it very challenging to understand when pronunciation is improper. This can especially be true when trying to listen and understand a language that is new to someone.
Quarternions allow you to specify the axis of rotation. This is very advantageous for some situations. Like rotating a virtual camera to a point at a specific vector, cross product of camera direction and specific vector is axis of rotation, dot product will give you the rotation angle. Euler rotations are good for specifying an objects orientation. I learned about Euler rotations in college and did not learn about quarternions until I was deep into my career. I think quarternions are useful enough that they should be taught in schools, they fit nicely with dot and cross product.
I appreciate your perspective and good examples of use cases for Euler and quaternions. It would likely benefit many to learn about quaternions earlier. Hopefully more exposure to quaternions finds its way to those who need it.
This is used in higher-level space vehicle dynamics.
This was the video that finally makes me "get it" for gimbal locks. Maybe its just the fact that I have been watching several videos of gimbal lock but walking away with a half-ass understanding of it. I think the way you put it - the gimbals have to make a wierd detour to get to an angle which requires rotation in that "lost" degree of freedom and the fact that when the gimbal lock occurs any rotation applied to that axis goes to the "stable platform" hence losing the priced orientation it contained is what made me add it up.
I am glad this video could be supportive in growing your understanding of gimbal locks! That detour concept can be tricky to comprehend at first, in combination with that "lost" degree of freedom. I appreciate hearing your experience, thank you for sharing it! :)
Euler angles are _compositions_ of 3 basis rotations. Quaternions are _mixtures_ (technically "linear combinations") of the same 3 basis rotations, but specifically 180° rotations around each axis, plus a fourth "0°" rotation term. Also important to mention: Quaternions are _rotations_ *not* *_orientations._* For every _orientation,_ there are two different _rotations_ that bring you to that orientation. These are often called "clockwise" and "counterclockwise," and in quaternions, the two different rotations have two different quaternions, which are also the negatives of each other. Interpolating quaternions only takes the shortest path with _one_ of these rotations, but not the other, which instead does take the long way around. Interpolating a 360° rotation is still hard because every possible axis will eventually get you to the right place.
"It represents something called 'the scalar value'" Which is a really fancy way of saying "doing absolutely nothing." It is the 0° rotation I mentioned earlier.
Regarding the world axis, that's exactly what quaternions do best. The world axis is a line which, when interpreted as a quaternion directly, is a 180° rotation. Mix in some "do nothing" in different quantities and you can get any rotation from -360° to 360° around said axis. (Be careful, vanilla quaternions can only rotate around the origin of the space you're using... or at least, _vanilla_ quaternions can.)
I like how you phrased Euler angles as compositions, and quaternions as mixtures. That seems like a helpful way to think of how the parts are used to form the wholes.
In the video I state that any set of Euler or quaternion values "represents a single orientation". Perhaps "results in a single orientation" may be perceived as more accurate when considering how Euler and quaternions can also be viewed for their rotational values.
On the topic of interpolation, I could have better specified that spherical linear interpolation (SLERP) with quaternions is what I was referring too. And after reviewing your comment it does appear that slerp algorithms for quaternions can produce either the shortest or longest path. It appears that this can be accomplished by negating one end of the values. I have been able to reproduce this, specifically in Blender. By manually negating a keyframe's quaternion values the interpolated rotation takes the longest route; However, for quaternions this only appears to work up to 359.99 degrees. Perhaps this is a limitation held by some 3D applications, or the algorithm itself.
Thank you for sharing your experience!
@@classoutside I'm pretty sure the limit of 360° is inherent. Quaternions themselves can represent any rotation around the origin with an angle between -360° and 360° exclusive on both ends. (For rotations _no_ around the origin, there is a small extension that's possible.) At 360°, it's caught at the exact halfway point not just between both directions, but _all possible_ directions. Being 360° though, it should be understandable that wanting to perform a 360° rotation isn't terribly common. In case you're wondering, the quaternion for a 360° rotation is -1, which you might notice is lacking any information about the axis it was around.
It's possible that 360° = -1 might look familiar to some, and not in a good way. No, it's not a complete coincidence that it looks like a spin-½ particle from quantum mechanics. There are however very good reasons for both instances of this phenomenon that _aren't_ inherently quantum.
There _is_ a way to visualize quaternions much like Euler angles. With Euler angles, the three values form a vector which points along the axis of rotation. The length of this vector is the amount of rotation.
It's much the same with quaternions: the XYZ components form a vector which points along the axis of rotation, but now it's the _ratio_ of the length of this vector to the W component which determines the amount of rotation.
I agree, it is possible to provide visualizations that are meant to represent quaternions. I appreciate your helpful explanation. Your description appears in line with my understanding and what I have seen in visualization attempts so far.
The challenge I face is I have not yet come across a visual example that I subjectively consider simple to comprehend, without some prerequisite knowledge or explanation of the math involved in the process.
Thank you for providing your perspective and input on this!🙂
Technically, visualizing the angle as the length is basically visualizing the _logarithm_ of the quaternion. Taking the exponential of that converts the magnitude into a mixture of 180° rotation around the axis in question and 0° rotation.
@@angeldude101 That doesn't make much sense. The magnitude of a quaternion is always 1 because pure rotations are always unit quaternions, so they always have a length of 1.
What @APaleDot said is also wrong. The 3 angles of a set of euler angles can be written as a vector, but that vector does not represent the rotation axis. This should be obvious from the fact that the same numerical representation (say 10,50,30) results in a completely different rotation depending on the used rotation order. There are 6 different conventions that are possible for euler angles. However it's true that a quaternion is simply a single rotation axis and the angle around that axis. You can easily construct a quaternion that rotates "D" degree around an arbitrary vector / axis V. First that axis vector has to be normalized, so has to have a length of 1. To create a quaternion out of those two pieces of information you just have to do:
x = V.x * sin(D/2)
y = V.y * sin(D/2)
z = V.z * sin(D/2)
w = cos(D/2)
That's all. That's your quaternion that rotates D degrees around the axis V. Unity and some other software uses an unusual notation for quaternions as the normal notation is (a + bi + cj + dk). What Unity does is essentially (w + xi + yj + zk)
The actual math is also quite simple but due to the number of elements will get quite convoluted. As you may know, in order to rotate a vector by a quaternion you have to do a "sandwich" multiplication. So you have to do q*v*q^-1. Here "q^-1" is just the "complex conjugate" of q. In the conjugate all the complex arguments are inverted. So q^-1 = (w - xi - yj - zk). The actual multiplication is pretty straight forward. Though you have to apply the multiplication rules for the complex identities i² = j² = k² = ijk = -1. The important part is the "ijk" because quaternion multiplication is not commutative. So the order of the multiplication matters. From those basic rules you can simply deduce:
i*j = k
j*i = -k
j*k = i
k*j = -i
k*i = j
i*k = -j
With those you just multiply the parenthesis. Multiplying two quaternions together results in 16 terms (4 * 4) but after applying the above mentioned rules they reduce back to just 4 terms. Again one scaler and the 3 complex bases i, j and k.
A unit quaternion can directly be transformed into a 3x3 rotation matrix since all members of the quaternion just contains the spatial orientation as well as sine and cosine values of the angle.
The reason for the sandwich multiplication is directly tied to the fact that we only use half the angle in the sin / cos. That's because we essentially rotate the vector twice. The first rotation however rotates the vector into 4d space. The second rotation essentially brings it back into 3d space.
If you want a concise explanation of quaternions, I can highly recommend the numberphile video on quaternions. For more details on how and why we need to apply the double rotation, watch the 3b1b videos on quaternions.
An important point to note is that in 3d space it's actually possible to get from any orientation in space to any other rotation in space by just rotating around a single axis by a certain angle. Because a quaternion represents exactly this axis / angle construct, it can be used to go from any orientation to any other orientation.
The concept of absolute orientation doesn't really exist, Any object has it's identity orientation which is just the way it was setup. So any other orientation can be seen as a relative rotation from that initial pose.
@@Bunny99s I actually follow a different convention for Quaternions, calling the basis Quaternions 1, ŷẑ, ẑx̂, and x̂ŷ, rather than "i, j, and k". A word of warning though, the basis as I've laid it out here actually has (ŷẑ)(ẑx̂) = -(x̂ŷ), and (ŷẑ)(ẑx̂)(x̂ŷ) = 1, rather than -1. You can however replace each basis element with a _sinister_ counterpart to restore the arbitrary identity of "ijk = -1". (Fun fact: "sinister" means "left-handed".) In fact, there are 48 possible quaternion bases (if you consider order to be important; otherwise it's only 8), only some of which satisfy ijk = -1, though all of them satisfy i² = j² = k² = -1.
Why is each basis element written as two parts? What does it mean for x̂ to exist in its own in this context? I'm quite glad you asked (or not so glad, if you actually didn't ask). The answer is that x̂ in this system is _not_ an arrow, but rather a _mirror;_ specifically the x = 0 mirror. Multiplication is composition, and a mirror composed with itself being you back to where you started, so x̂² = 1. x̂ŷ is just a multiplication between x̂ and ŷ; a composition between two orthogonal mirrors, resulting a rotation by 180° around their intersection x = y = 0 (more commonly called "the z-axis", regardless of whether or not the problem is in 3D).
To undo a rotation, you need to undo each reflection in the opposite order they were composed. (x̂ŷ)⁻¹ = (ŷ⁻¹)(x̂⁻¹) = (since x̂² = ŷ² = 1) ŷx̂ = -x̂ŷ. If the rotation isn't normalized, then you have to divide by the squared magnitude, which in some contexts may be cheaper than multiplying by an inverse square root. The sandwich product is simply composing a rotation (or other transformation) with some object (represented as a transformation itself), before undoing the first transformation: ABA⁻¹, or A⁻¹BA depending on your convention; whether you compose from right to left, or from left to write.
I don't know what you mean by what I said being wrong. Quaternions being normalized is nothing more than a convention to make taking the inverse simpler. When taking the exponential of a non-normalized quaternion with no scalar part, it converts it into a normalized quaternion whose rotation covers a sector of the unit circle whose area is equal to the magnitude of the input. The logarithm simply does this in reverse: converting a quaternion into a different quaternion around the same axis whose magnitude of its non-scalar part is the area covered by the rotation while its scalar part is the logarithm of its total magnitude. Said magnitude is usually 1, so the logarithm of that, and by extension the scalar part of the output, is usually 0. exp(a + B) = exp(a)exp(B) = exp(a)(cos(|B|) + Bsinc(|B|)). Yes, that is the sinc(x) = sin(x)/x function. It's easier to write than normalizing B.
For more information on this approach to Quaternions, check out A Visual Guide to Quaternions and Dual Quaternions, presented by Hamish Todd at the Math and Game Development Summit.
Good explanation! Thank you for your class!
This deserves so much more attention thank you so much!
I appreciate your kind words! I am glad I could share this video with you :)
Having known quite a bit on that subject, math and Blender wise, I saw "Class Outside" under the most human thumbnail I've looked at in days; Surprised this was a Blender/Graphics tutory, but the overall atmosphere of the video was entraping and calming.
You sir, have a great mind; stay focused!
Your experience and compliments brought me a smile! Thank you very much :)
Quaternions not caring about order is just wrong. pq =/= qp in that skew field. Just take (0, 1, 0, 0) and (0, 0, 1, 0) with the respective i, j and k values. It is not the same. You also did not touch upon the double cover properties of Quaternions. Thats why you have Angle/2 in the formulars concerning them.
That’s clearly not what they meant.
They meant that, for example, 3/5•i+4/5•j is the same as 4/5•j+3/5•i; each one is a single number (transformation).
In the video they were clearly talking about the “parts” of a rotation around each axis. And quaternion don’t split the rotation into parts, so their components do not need to be in any particular order.
I agree with you @fullfungo4476. I was referring to the order of components themselves. With Euler, XYZ will not necessarily produce the same result as ZYX, the order the values are represented matters. With Quaternions, you regularly operate in the order w i j k and do not need to be concerned about choosing a particular sequence. I appreciate you mentioning this @friedrichfreigeist3292, perhaps I could have made this more clear in the video. Further, by double cover i believe you are referring to the quality that each rotation can be represented in two ways. For example (w, i, j, k) as (0.1, 0.2, 0.3, 0.4) would appear the same as (-0.1, -0.2, -0.3, -0.4). I believe this is an important quality of quaternions. I believe this was left out of the video to retain focus on the key functional and distinguishing factors that I consider separate Euler and Quaternions when using 3D software.
That was a really good explanation, thanks!
Your compliments are appreciated, thank you!
my friend was talking about "rotors"
I wouldn't be surprised if there was a dozen theses on Euler angles with Quaternions.
There may be many theses that involve Euler and Quaternions! I have not checked but perhaps!
Thanks I think both gimbal lock and quaternions finally clicked for me
I am pleased I could share this with you and help grow your understanding around gimbal lock and quaternions! ☺
Tooo good! Thanks for the informational video!
I am glad I could share this with you! Thanks for your feedback :)
for almost all rotations, euler rotation will not return the smallest possible angle.
for small angles, quaternions suffer a too big precision-loss.
matrix of axis angle rotation is identical to quaternions, but axis-angle-forms needs more memory and multiplications, usually not worth the gained precision, unless you do less than 2 rotations in a chain-sequence and precision really matters.
the second life wiki has a function, that reasonably efficiently first calculates the angle, and then only does euler-rotation if the angle is small enough so that precision of the result matters more than rotating around a single axis.
I appreciate hearing your input. Taking the shortest path, or smallest possible angle, when rotating is often found when using spherical linear interpolation (SLERP) which is more common with quaternions, not euler rotation. As precision needs grow, it can be important to ensure calculations take those needs into account. I believe for 3D art and animation quaternions or euler values may be precise enough for most applications. I would have to research further to identify where either begins to be less precise. Computational efficiency can be very important. I was not aware of the second life function, thank you for sharing.
(note: I'm not a mathematician and I don't understand quaternions, the following is based purely on my experience as a game dev)
Gimbal lock doesn't actually happen tho.
If you stop thinking about gimbals, you can rotate an object according to euler angels at any given time in both absolute and local space
Gimbal lock would only occur if you rotated a world axis with the rotation. Which doesn't actually happen.
You either don't rotate any dimensions (absolute space) or you rotate all dimensions (local space)
I believe it is true that often in general rotations in 3D software like Blender or game engines may not visually experience gimbal lock. It is common for the code of this software to work with quaternion values even if visually the rotations are represented with X, Y, Z Euler. I do believe there are times where the affects of gimbal lock may be experienced when using 3D software. For instance, a script to programmatically rotate an object may directly affect the rotation with Euler values, rather than with quaternions. Another example would be in blender, if part of an animation is indicated to rotate around an axis, you may see other values begin to change unexpectedly as the animation plays. This may not visually appear similar to gimbal lock because the software is attempting to compensate for it; However, the result of unexpected XYZ values changing is an effect of the gimbal lock concept.
Euler: paltry three dimensions...
Quaternions: FOUR DIMENSIONS!!!!
Haha! While they both have their pros and cons, Quaternions certainly has the edge on dimensions!
How many dimensions between the 3'rd and 4'th Floors, in this "If Zero/Then One" edifice....
I have a Tree House at 3.5 the Swiss Family Robinson would envy!
Very helpful, thank you!
I am glad you found this video helpful. Thanks for your feedback :)
I wrote code for a 6DOF platform. Not only does the order make a difference but the direction of rotation must be defined. You can use the left hand or right hand rule. So there are many ways of moving the 6DOF platform. Rarely would two people get the order and directions the same. This was a problem because a flight simulator would down load x,y,z, yaw, pitch and roll but often the 6DOF would move as the customer thought it should. I finally decided to use the NASA's Glen Research centers standard and told people to use that. I need to figure out quaternions but the 6DOF platform doesn't make big angle changes.
Thank you for sharing your personal, hands-on, experience solving problems with concepts in this field. It sounds like it can be challenging when customer expectations do not initially align with common or planned for results, and standardization can help in these situations. I appreciate your input!
Just learned I lean to the Quatereulerions.
"Ka-ter-oil-ler-ons" ...
Alright..........I'm re-naming my new team:
"3.5'ers"
...
We took a left at Albuquerque!
This way to think about quaternions and eulers is new to me. Thank you for sharing
Great video and explanation of gimbal lock. Though I think you could have spent more time on at least giving a brief explanation of what the four quaternion numbers represent / relate to (i.e. rotation axis and angle), even if you avoid the math or attempts at 4D visualization.
The amount of 180° rotation around the x-axis, the amount of 180° rotation around the y-axis, the amount of 180° around the z-axis, and the amount of 0° rotation around no axis. These four basis rotations can be mixed together in varying proportions to get any rotation around any 3D axis through the origin by any angle between -360° and 360°.
@@angeldude101 Yup. I'm more of a math guy, but friends in game dev say it's one of the more confusing topics they can never get satisfying answers to.
@@tedsheridan8725 Of course it's confusing when all you're taught is that it works and never why it works. When you actually understand the math, it all makes _so_ much more sense. Even the angle doubling feels inevitable to me now rather than a bizarre artifact that needs to be dealt with.
@@angeldude101 It must be quite hard for non-math people to wrap their heads around the details - trying to learn complex numbers AND 4D at the same time is bonkers. The "mixture of rotations" model is easier to understand, you just have to get used to the quirks. I started a math channel that will among other things explore 4D shapes - there will definitely be a quaternion video at some point.
Thank you for your compliment and suggestion. I agree, there may be value in providing some more information about what the values represent, even without sinking too deep into the math. If I get to iterate on this video some day, I intend to use this feedback to make it even better!
nice stuff
Thank you!
Thank u i need to write a thesis dealing with the basics of 3d and this is helpful (no stem baxkground..)😅
I am glad this video could help support you! Good luck on your thesis.
doge had me cracked up, thanks for that lol
Haha, I am glad i could help bring you a laugh with the dog! Thank you for sharing
thanks for the 10 min trip outside from basement lab
I am happy to share this brief trip outside with you!
Orientation and direction are not the same thing. The fact that 3D orientations are representable with 3 Euler angles is just a coincidence. In 2D you only need one angle, and in 4D, you need six.
In general, you need N coordinates to represent an N dimensional point, and (N^2+N)/2 angles (or bivectors) to represent an arbitrary rotation.
Orientation and direction may be known to have distinctions. I appreciate you pointing this out.
The term orientation used in the video is meant to describe the rotation of an object relative to some reference position. In some of the graphics an arrow is imposed on an object to provide an arbitrary 'face' to better visualize how the object moves during the animation. I believe direction is commonly used in reference to the specific way something moved over time. I have also heard it used to represent the area with which something is pointing towards, whether or not that something is mobile.
The underlying math behind 4D and higher rotations appears interesting.
Ah, so I'm not the only one here familiar with the Geometric Algebra approach to quaternions. Also while any given dimension has N choose 2 distinct basis axes, each dimension has a total of 2^(N-1) components for a full rotation. This is 2 when N = 2, just like a Complex number, 4 when N = 3, just like a quaternion, and 8 when N = 4, which is actually not like an octonion, but rather is more like a dual-quaternion.
I find geometric algebra the easiest formalism for orthogonal transformations.
Thank you for sharing your perspective. There are many ways to view rotations in 3D space, and each come with their own quirks and benefits.
Bingo!
well actually, normalized quaternions may be used to represent spacetime and relativistic calculations and transforms between reference-frames, where w then is time of spacetime. But this is usually not a good way to do those calculations, almost certainly too slow AND too low precision in the needed context, compared to simpler functions that calculate the same, without relying on quaternions or complex numbers.
It is interesting to consider how quaternions may be used in various ways, and the challenges like computational needs that come with them.
You can pronounce him as Ey-ler, Эйлер in Russian. Euler lived in Russian Empire, published in Russian, and that's how he was referened to and self-referencing for years.
I was not aware of many of the details of Euler's life. I appreciate you sharing this bit of information here.
2:36 perfect describe of me after heard that, I has to track back and still can't stand that sentence😂
.
Anyway great video is solve lot of question in my head.
Haha! Yes, 2:36 described me at one point too! In Euler, order matters, so X=90, Y=90, and Z=90 may output a different result when the rotations go in the order: 90 degrees on the X-axis, 90 degrees on the Y-axis, and 90 degrees on the Z-axis, compared to the result we get when the order rotates along the Y-axis first, then the X-axis, and finally the Z-axis. I try to visually display this between 2:45 and 3:33.
I appreciate your compliment, and I am glad this video could help solve some of your questions :)
So.... to animate rotation in unreal i have to rotate the object using 2-3 keyframes????WUUUUT
When animating in unreal you may be able to mark keyframes agnostic of rotation type (Quaternion vs Euler) and instead rotate around the world axis with other controls. I would recommend trying this first and monitoring the output.
If you were to use Quaternion values to represent the keyframes in the rotation, you may need to use 2-3 keyframes. While under some circumstances it can be argued that Quaternions can represent a 360 degree range of values, it may not be able to accurately represent a desired angle taken to traverse from 0 to 360 to perform a full rotation.
I hope this helps.
Quaternions didn't make sense to me until I learned about "Geometric Algebra", Hestenes, etc. They are very simple after seeing it from that point of view. Thinking of them as an unvisualizable 4D object isn't helpful.
I appreciate your feedback and resources that may help others interested in learning more about quaternions. While in the context of 3D software I don't believe it's necessary to visualize quaternions in order to apply them in a useful way, I would encourage those looking to understand more of the detail behind quaternions to continue seeking visual aids for this topic until they find what is right for them.
To make the backflip with a Quaternion, why couldn't you specify the 180 degree angle to rotate to then again back to 0, instead of the way you did it with two points through which the quaternion rotated through, for the dog on a skateboard backflip?
Spherical linear interpolation (SLERP) is usually how the paths between two quaternion rotations are determined in 3D software. For SLERP this takes the shortest path from one rotation to another, which will always be 180 degrees or less. While performing 3 separate rotations all below 180 degrees is adequate, there is potential to perform an animation like the backflip with only two 180 degree rotations. To perform it this way does require understanding a bit more about quaternions.
In quaternions any 1 rotation has at least two ways to represent it. The rotation represented by (0.1, 0.2, 0.3, 0.4) should be identical to the rotation represented by the negative equivalent (-0.1, -0.2, -0.3, -0.4). What is different is the direction rotated to achieve these new orientations. Since any orientation is represented by two values, 180 degrees along the x-axis may be represented by either (0,1,0,0) or (0,-1,0,0). While both of these will end in the same position, one will reflect a backflip, and the other will look more like a front flip. While it is possible to perform a backflip or frontflip with 180 degree rotations and quaternions, keeping rotations below 180 degrees may come with fewer challenges when animating.
@@classoutside thank you
Excellent
I am happy I could share this with you!
I wonder if someone can manufacture a 4 ring device which has no gimbal lock
A 4 ring device with no gimbal lock sounds like a very interesting one I would be interested in seeing!
great vid
I appreciate your compliment 😊
Well, without numbers it’s quite hard to convey something.
Numbers can be very useful in conveying concepts. With this video, my intention was to provide information about the conceptual differences of Euler and Quaternions, without entering into the underlying mathematics of them. Perhaps some day i will have another video that explores more into this topic.
Thank you for your input, and sharing your experience!
Apollo craft were vulnerable to gimbal lock.
If the tools we build, like spaceships, are chosen to use gimbal-like mechanisms, they too may be affected by gimbal lock. An object floating freely, like a spaceship, with forces applied to it, or mechanisms not constrained to gimbal-locking, will be free to rotate in all directions.
Thank you for sharing this real world example!
What about Rodriguez formula / axis, angle? No Gimbal lock and intuitive?
The Rodrigues' formula and axis, angle representation may have benefits depending on how they are being applied. In this video my intent was to focus on Euler and Quaternion representations due to their adoption in popular 3D software tools.
I appreciate your call out, and sharing this additional way to handle rotations.
I prefer Directional Cosine Matrix (DCM) 9 elements and gets around that 90 degree problem.
Directional Cosine Matrices seem like an interesting solution to the 90 degree problem. I wonder how their implementations may be found in common 3D software programs.
Thank you for sharing!
"Euler" as in Houston Oilers (NFL) or Edmonton Oilers (NHL).
Those are even more words that rhyme with Euler! Good call out!
slerp it up
SLERP is an interesting acronym that doubles as an onomotopoeia!
Euler angles just aren't nice. Unit quaternions and 3D rotation are both groups, and unit quaternions have a 2 to 1 homomorphism to 3D rotations.
Euler angles do seem to come with many complications. The fact that quaternions have at least 2 ways to represent any single 3D rotation does stand out!
Geniua marketing to get the island sold. I wonder which politician has a stake in the sale. They will let it carry on and someine else will buy it to maje a stand.
I am not sure how marketing and island sales may be relevant to Euler and Quaternions. Perhaps there is some context i am missing.
@@classoutside sometimes when I watch a video and comment it posts the comment on the previous video lol it's a problem with the TH-cam app only happens on the phone.
Ah! I thought it might be something like that. Thank you for sharing.
@@classoutside great video though thank YOU for sharing :))
The pronunciation game for Euler is the biggest meme. Who cares
Thank you for sharing. Effectively communicating concepts with others can be challenging. Pronunciation rules can be relaxed in some settings and still lead to effectively discussing the same topics. I have met some people who find it very challenging to understand when pronunciation is improper. This can especially be true when trying to listen and understand a language that is new to someone.
You explain things very impressively🤩but your graphics, mesh gradient, model material made me sick!!🤮 Try minimal graphics
Thank you for your compliment and feedback. I will continue to consider how the graphics may affect the experiences and look for ways to improve them.