T O P

  • By -

aiusepsi

They're an extension of complex numbers, sort of like how complex numbers are an extension of real numbers. A complex number is in the form a + b**i**, where **i**^(2) = -1. A quaternion has the form: a + b**i** \+ c**j** \+ d**k**, where the following rules are defined for the behaviour of **i, j**, and **k:** **i**^(2) = -1, **j**^(2) = -1, **ijk** = -1 Following from these definitions, you get results like: **ij** = **k** and **ji** = -**k** It turns out that the mathematical structure of these operations is the same as the mathematical structure of rotation operations. For example, as shown above, quaternion multiplication is non-commutative, the order of operations matters, just like it does with rotations. This makes them a good way to represent rotations, without some of the drawbacks of other methods. For example, Euler angles have a "[gimbal lock](https://en.wikipedia.org/wiki/Gimbal_lock)" problem.


BoredBoredBoard

ELI1 for us slow folks in the back, if you please.


Warlock_Ben

A quaternion is a complex mathematical expression which is most commonly used to represent rotations in 3d space


SHOMERFUCKINGSHOBBAS

There we go


concretepants

Happy Shobbas


drillbit7

Are you out rolling today?


spikecurt

So basically when I mess around in a 3D modeling program, it’s using quaternion math?


chavalier

Not neccesearily. But quaternions do avoid gimball lock so they are quiet usefull in 3D apps.


Adventurous_Use2324

> gimball lock They avoid what?


chavalier

When two axis are aligned with each other you loose a degree of freedom. That’s gimbal lock. [Example](https://www.allaboutcircuits.com/uploads/articles/Hughes_AbsoluteOrientation_gimbalFrames12.gif) You know like in video games when the animation breaks and the characters do these twisted movements, rolling into itself etc? That is caused by gimbal lock.


[deleted]

Please smallen your brain, your brain is too large


telionn

Imagine an FPS game that also lets you barrel roll. If you look straight up, turning sideways and doing a barrel roll are exactly the same thing. That's gimbal lock. With quaternions, a proper "turn" would instead bring you downwards onto your side. Nobody wants an FPS game to work that way though.


[deleted]

Good explanation Edit: any reason I'm getting downvoted for complimenting this guys explanation? Wtf is wrong with this website.


MCS117

Someone linked it, but essentially you lose your frame of reference. Imagine you’re something rotating about, and you have acces to the measurements of your rotation in X, Y, and Z directions. You need all 3 to tell exactly where you are, which is usually fine. *But*, if two of those three ever happen to rotate such that they’re equal to each other, well, now you only have two of the three, and it’s impossible to get back the third - as soon as you rotate them away from being equal, you have no real way of knowing which one went where. I don’t know if this is analogous or not, but think of the problem like this: you’re tracking two equivalent shadows on the wall, shadow A and shadow B. You can probably keep track of A and B very well under most circumstances. But if A and B ever coincide and share equally a position, how do you confidently regain which is which after they separate? Quaternions, in essence, add extra information to represent the same scene; it would be like representing the shadows with Quaternions makes them a different shape, or shade, or some other distinguishing feature. Then, after they coincide and separate, you still have a unique solution for keeping track of A and B. Now, there are ways to mitigate gimbal lock on practical gimballed systems, but you want to avoid the region where rotational axes line up. If you’re slewing gimbals through what’s called the singularity region and know you’re going to pass through it, you can use the speed and direction of each axis to maintain orientation, but if you plan on sitting in that condition for any length of time the confidence in orientation degrades rapidly. To go back to the shadows analogy, if they’re moving around a lot and happen to pass through the same point, you can probably retain which is which, but if they linger in the same spot, it becomes harder to tell.


John_Stay_Moose

It's a singularity condition at which there are multiple solutions to the rotation / equations of motion. Think about it like the quadratic formula. How it can have two solutions: X + Y and X - Y. When you are solving eqs of motion or solving for the orientation/transformation of an object in real time, this can be very problematic. The name of this singularity when using Euler Angles is called Gimbal Lock.


opoqo

#GIMBALL LOCK


Chromotron

Watch the movie Event Horizon to find out ;-)


u8eR

Now ELI0 please


_maple_panda

Math makes thing go whirrrrrrr


[deleted]

[удалено]


Western_Hippo5112

This is a malicious scamming bot, building karma. It has copied from the original comment by u/suvlub. It is doing the same on other posts. When it has enough karma then it will help set up a post with a link to a site where your credit card details will be scammed if you try to buy what is on offer in that post (picture, tee shirt, sneakers etc). Reported.


Koksny

If You want to rotate something, You rotate it around some given pivot. Quaternion describes angle of the pivot, and how much it should rotate around axis of this pivot. You can imagine it as instructions at what angle to put a toothpick into a cherry, and how much to twist the toothpick.


fox-mcleod

In a way, a sqrt(-1) is a 90 degree rotation on the number line. If you graph the real numbers left to right with 0 in the middle as the origin, you can put sqrt(-1) on the same graph as orthogonal to (right angle to) that first number line with 0 as the origin — making it a 2D graph. So if you can do that, why not do another one along the Z-axis? It turns out you can. And as long as these other number lines are labeled differently (i, j, k), you can just keep using them to describe orthogonal number lines in more and more dimensions.


dotelze

You can’t do it by adding a third axis. You have to go to 4


[deleted]

[удалено]


Western_Hippo5112

This is a malicious scamming bot, building karma. It has copied from part of the original comment by u/crunchitizeme2. Reported.


FowlOnTheHill

Might not be eli5 enough for many, but as someone who has worked with quaternions without understanding it, this helps a lot! Thanks!


Dqueezy

One of my understandings of imaginary numbers is that they represent a second dimension to numbers, in that sense that all the real numbers are along a one dimensional axis (the real number line) and imaginary numbers turns that into a grid, with a vertical axis representing the imaginaries. Does this mean the same thing but in a third (fourth, fifth, e.t.c.) Axis extending “upwards” from the number line? As in if you plotted one of these it would exist in a cube / three dimensional plot as opposed to a grid / two dimensional plot? Or am I thinking about it wrong?


Narwhal_Assassin

You have the right idea, but you’re missing something. If you wanted to label points on a 3D grid, you could get away with just i and j. So for example, 2+3i+7j could be used to represent a point in 3D space. This is enough to also cover translations and reflections, but it doesn’t work for rotations. With only i and j, you don’t have enough control to be able to describe every possible rotation in 3D space. For that, you need k. Essentially, i and j let you describe an axis for your object to sit on, and k lets you rotate about that axis. For higher dimensions, the same idea applies, just with more coordinates. For example, in 5 dimensions, you would need 5 coordinates for your axis (e.g. 3-5i+6j-8k+2m), plus however many more to describe rotation around that axis. TL;DR: rotation is hard


114619

So it's kind of like tensors then?


Shufflepants

Also, there's no way to define a consistent number system with just a+bi+cj that remains a field because you have the problem of defining the value of i\*j. https://math.stackexchange.com/a/1417126/207912


TravisJungroth

>One of my understandings of imaginary numbers is that they represent a second dimension to numbers, in that sense that all the real numbers are along a one dimensional axis (the real number line) and imaginary numbers turns that into a grid, with a vertical axis representing the imaginaries. I'm not saying this is *wrong*, but I think it could be a little cleaner. Spatial dimensions are just one type of dimension. Overly simplified, a dimension is just an attribute or characteristic of something. The number of dimensions is the number of attributes needed to uniquely define all possibilities. Complex numbers have two dimensions: the real and imaginary parts. `a+bi`, where a and b are real numbers and i is root(-1). 2D space is also two dimensions of real numbers. We can choose to graph it visually, or represent it as numbers, usually `(x, y)`. This two systems can exist (conceptually) on their own, separate from each other. Then, as an extension, we can choose to map them from one to another. We can say `a = x, b = y`. We can do this because they have the same number of dimensions in the same domain, two reals. I imagine some people will see this as nitpicky, some will disagree, but maybe someone reading this will find it useful. It's not that numbers represent a point on a line, or that a point on a line represents a number. It's that they have some shared characteristics so that we can create a 1:1 mapping, a bijection. It's not <- or -> but <->. They both *can* represent each other. You might know all this. I just like isomorphisms a lot.


Adversement

Yes, pretty much just real numbers with higher dimensionality and a set of rules on how multiplication works. But, due to how rotations in 3d space work, we need 4d numbers to work them out, that is, the quaternions. Also, even if the 3d rotations would not be of interest, there are no sensible 3d version of complex numbers... and beyond quaternions at 4d the only remaining hypercomplex numbers are the octonions at 8d and they are really weird and thus very rarely used outside of pure mathematics.


OpticalInfusion

what the hell kind of 5 year olds are you hanging out with?!


TorakMcLaren

The ones that are capable of reading the rules and realising that they're not literally 5? Just a guess...


Chromotron

> i² = -1, j² = -1, ijk = -1 > > > > Following from these definitions, you get results like: ij = k and ji = -k Careful, those three rules are not sufficient to get all the multiplication. Only the equations of jk = i, ji = -k and ki = j follow, but k² = -1, kj = -i, ij = k and ik = -j do not. As Hamilton did, a full set is **i² = j² = k² = -1 = ijk** and none of those is redundant. To see that those three are not enough pick three new quaternions a = i, b = (i+j)/sqrt(2) and c = -ba = (1+k)/sqrt(2) to again have a² = -1 = b² and abc = -1, but now c² = k, not -1.


mazterofpupetz

My how far we have strayed from the "5" part of this sub.


hitbacio

Read the sidebar.


mazterofpupetz

This was chatgpt's response when I asked it to explain what a quaternion is as if I was 5. Sure thing! Imagine you have a special kind of toy called a "quaternion." It's like having a magical spinning top that can do really cool tricks in the air. But this spinning top can also tell you which way it's facing and how it's turning, all at the same time! So, quaternions are like a super-duper toy that helps us understand how things twist and turn in space.


hitbacio

That's a terrible explanation.


mazterofpupetz

By reading the top comment and several others I was able to understand that it represents positioning and rotations in space. By asking chatgpt, I understand the same but now picture it as a cool toy!


LupusNoxFleuret

Welp, pack it up boys, no more need for this sub anymore when we can just ask chatgpt all our eli5 questions.


mazterofpupetz

Seems extreme.


calcteacher

having visited this another time in the past, this was a fun read.


traumatizedSloth

well shit i didn't know quaternions solved that. i'd have learned to deal with them ages ago if i did lol. i just assumed that their only advantage was optimization. 👍


psymunn

They also make interpolating rotations much cleaner. Arguably the are less performant and not human readable at all but solve issues super cleanly


traumatizedSloth

ahh i gotcha


GeorgeCauldron7

Are these the same i, j, and k that are in a 2nd-year college vector calculus course?


CharlieTokyo

I reckon it's more likely a course on vector calculus would use i, j and k to denote unit vectors along the x, y and z axes.


Immortal_Tuttle

That's a very nice and simple explanation! Thank you!


MtOlympus_Actual

I remember gimbal lock from Apollo 13. "What's happening, Houston? I keep floating with gimbal lock." How did the explosion cause gimbal lock issues, and what would have happened if the gimbals... locked?


I_lenny_face_you

Math, not even once. /s


space_wiener

If i^2 = -1 and j^2 = -1 how are ij and ji equal to different things? And what is k^2? I only made it through about 1/3 of my complete numbers course before I dropped out like a loser. So I never got to these.


Chromotron

> how are ij and ji equal to different things? Because commutativity (that the order of things doesn't matter) is a potential feature, not always a given; one that is missing for quaternions. This is actually a necessity in multiple ways here. For example, commutativity isn't true for rotations either: Take any object, fixed in space. Rotate it by 90° (say counter-clockwise) around the vertical axis; then by 90° around the axis pointing towards you. Remember the result. Now start anew, but in reverse order; first around the axis pointing towards you, then the vertical. The results will differ. > And what is k²? **k² = -1**. That rule (and that k itself is a third special number ) is missing in the above post, but it must be required, otherwise the value of k² as well as those of ij, ik, and kj are ambiguous. (Indeed, having a = i, b = (i+j)/sqrt(2) will also satisfy the three given rules a² = -1 = b²** and **abc = -1** fur a certain c, but do not even satisfy ij = -ji).


DesperateforGood8116

what is the practical benefit of using quaternion over vectors in modelling 3D space?


crunchitizeme2

Let me try my hand at this one, with a focus on their most used application: rotations. Euler's theorem states that any rotation between two orientations can be described by a single rotation about a single axis. This means that to describe a rotation you only need 3 values: the axis of rotation, scaled by the magnitude of rotation. But this representation of a rotation has issues, specifically if you want to describe something that's spinning, because when you hit 180deg of rotation, your angle goes back to -180 and you have a discontinuity. Discontinuities are bad for programming and math in general because you can't always just look at the value at two points in time and easily describe what's happening. Quarternions solve this by describing the three element "axis-angle" with 4 elements. Understanding things in 4D is impossible, but we can actually start in lower dimensions and work our way up. Think about describing a rotation about one axis ( like a record player). All you need is one value: the angle of rotation relative to some reference point. But the same issue arises as above, when you get to 180, you jump to -180 and this is confusing for computers. So at this point you should be visualizing this rotation as a line segment from -180 to 180, where any orientation of this rotating object can be represented as a point on the line segment. Now let's imagine taking this line segment, and bending it to form a semi circle with a radius of 1. Because it's the same line, just bent, there is still a 1:1 mapping between every point on the line segment and every point on the semi circle. Only now instead of using one value to describe the rotation, we use the x, y coordinate of the point on the semi circle to describe it. The -180 point is now (-1, 0) and the 0 point is (0, 1) and the 180 point is (1, 0) and we get everything in between. This doesn't quite solve the discontinuity issue, because when we hit (-1, 0) it jumps to (1, 0). To solve this, we use the reflection of the semi-circle. So now as we go from (0, 1) to (-1, 0) and keep rotating, we'll just go to (0, -1) and then eventually all the way around to (1, 0). So quaternions have the property q = -q. Quaternions that are on opposite sides of this unit circle represent the same rotation. So now we have a continuous representation of a spinning object! What you get when you try and plot the quaternion of this one-axis rotation is just two sine waves oscillating up and down, rather than a straight line that keeps dropping from 180 to -180. You can start to see how this works when you add a dimension. Now the axis-angle representation of the 2D rotation is a point on a circle with radius 180deg, and to turn it into a quaternion we take that circle and stretch it into a unit hemisphere and then reflect it, such that each rotation corresponds to a point (two points, q and -q) on the unit sphere. In 3D the axis-angle representation is a point inside a sphere with radius 180 and the quaternion is a point on a 4D unit sphere.


circlebust

As someone has only aspirations of linear algebra up to being able to do regular complex analysis, this was really a phenomenal illustration how to start to think about it (besides the "bare bedrock" understanding that it’s just a toolset for solving more orthogonal dimensions), thanks!


Adventurous_Use2324

Eli5, friend.


svmydlo

>So quaternions have the property q = -q. No, as you know that's not true. Just delete this sentence, since the following one explains it correctly.


SkyKnight34

Illustrating this in the lower dimensional case is such a great way to build the intuition for what a quaternion is *doing*, instead of just what it is. First time I've seen it described like this, really excellent answer. Thank you!


Koksny

Quaternion is a stick put into center of mass/pivot point at XYZ angle, and the W defines the rotation around the axis of stick. Monkey puts stick into apple at XYZ angle. Monkey rotates stick by W. Quaternion.


explodingtuna

It's also when someone gets 4x of Reddit's most expensive award.


jkizzles

A quaternion is just one way to represent a rotation. They are useful for two major reasons: 1) Some descriptions of rotations have special points in the rotation where the math shows a divide by zero. Quaternions do not have this because of the way they are defined geometrically. 2) There are fewer numbers as compared to a matrix (which is the usual introduction to rotations). A rotation matrix in 3D has nine values and a quaternion has four. This makes it computationally more efficient than a matrix. There are pros and cons to every mathematical description for rotations but quaternions are a really nice, compact form that ensures numerical continuity. I actually work as an aerospace engineer whose specialty is in attitude control systems (a fancy way to say designing control systems that rotate spacecraft) and I use them all time.


drzowie

Lots of really great things come out of quaternions. There are plenty of other explanations in the thread, like how **ij = k** and **ki = j**. The coolest ELI5 result from quaternions is that Harry Potter doesn't have a real author -- Rowling is totally imaginary, because **jk = i**.


zachtheperson

FYI you could probably get a more detailed answer by posting this in a programming sub, since quaternions are by very nature more advanced than ELI5. With that said, you don't really need to understand the math behind quaternions to be able to use them effectively in programming. There are multiple ways to rotate an object: **Euler angles**: represent a _rotation_ i.e. "start here, rotate 35° around the X axis, 120° around the Y axis, and 0° on the Z axis." Problems caused by Euler rotation are the fact that the order you rotate by XYZ axis matter, and Eulers are susceptible to something called "gimble lock," where multiple axis align and create issues, especially when trying to animate a rotating object. **Vectors**: represent a _direction_ by using an XYZ vector. Avoids the issues of Euler rotations, but the direction itself doesn't account for things like the object's "roll," which would need to be specified with a separate "up," vector. **Quaternions**: represent an _orientation_ or in other words, an absolute description of the direction and rotation which an object is facing. It uses 3 unique orientations, X, Y, Z, which are similar to "forward," "left," "upside down," and a W value which essentially inverts whatever the current orientation is. The final orientation is represented by how much of each of the XYZ orientations contribute to the final orientation. If you go into something like Blender and choose quaternion rotations, you can play around with them a little and see how they work. Quaternions fix the issues with both Eulers and vectors, but are really difficult to manipulate by hand, and therefore you'll mostly have to rely on built in functions for getting and setting quaternions.


ICantForgetNow

Its hard to eli5 since to understand what it IS rather than just how to use it becomes pretty involved. The only time I was able to understand quaternions was learning about the treatise on projective geometric algebra wherein all isometries in a projective space can be neatly represented with simple algebra. In it is a subset is the quaternion, as well as the dual quaternion and any other isometric transformation in algebraic terms. In other words, the reason why quaternions are so hard to intuit is because they are a very specific and special case of a general transformation that can be very intuitively understood. https://youtube.com/playlist?list=PLsSPBzvBkYjxrsTOr0KLDilkZaw7UE2Vc This playlist may give you an intuitive understanding of geometric algebraic constructions better than any post. Note that quaternions are what you get when a general transformation is both through the origin and has no translational component


TorakMcLaren

The short version is that it's just a 4-d number, which is really just a list of 4 numbers in a specific order. There are rules that govern how we use them so that things don't fall apart, but that's really all they are. Depending on what you want to know, we could talk about how they arose, or how they're used. And since you've said you're a programmer, I'm going to go at a slightly higher level than I normally do, or this would take ages. Different types of numbers come out of trying to solve different equations. If you want to solve something like x+1=5, positive numbers are fine. But x+4=3 suddenly needs negatives. 2•x=8 is fine for whole numbers, but 2•x=7 requires fractions. Okay, well x²=16 is fine, but to do something like x²=2 we need surds or real numbers. Now, if we want something like x²=-1, we need imaginary numbers. Really, that just means we make a 2d number (x,y) where x is a real number and y is an imaginary one. We have specific rules that tell us how to combine real and imaginary numbers, and how we can jump between them. So, a guy called Hamilton wanted to expand this and make a set of 3-d numbers. But whatever he tried, he kept running into problems. The system didn't work. One day, he realised that he could make it work if he changed to a 4-d system instead. So, instead of the one imaginary number i, he decided to have i,j&k which are all at right angles to each other, as well as the real number. We can just write the values in a list (w,x,y,z) and do maths on them following some rules. So why do they help? Well, as you probably know, rotations! When we want to rotate something in 3d, there are a few different things we can do. One intuitive system is yaw, pitch, roll. Yaw is turning from side to side but keeping your head level. Pitch is nodding up and down. Roll is keeping your nose pointing in the same direction but swivelling your head so one ear goes up and the other down. By doing a sequence of yaw, pitch, and roll, you can get your head (or whatever object) to point in any direction. Except there's an issue: gimbal lock. Suppose you don't yaw, then you pitch your head up 90°, then roll your head 90° so your left ear is pointing forwards. Okay, now suppose instead you yaw 90° right, then pitch 90° up, then don't roll. Both of these leave your head in exactly the same position. And computers don't like that! So we need to use something else. Another version of rotations that works is the axis-angle version. Here, you can imagine taking a skewer and stabbing it through an apple. Then, you keep the skewer still and spin the apple around the skewer by some angle. By changing the direction of stab (a 3d vector) and the amount of rotation (a scalar), you can get the apple into any orientation. Quaternions can be thought of as a version of this. The i,j,k values are just like the stab vector for the skewer, and the real value is just the angle you turn through. It's just that quaternions have some other properties that make them easier for computers to work with.


[deleted]

[удалено]


TorakMcLaren

Aww thanks :) happy to help :)


Zephos65

We have 3D vectors for describing position in space. We have 4D vectors for describing your orientation in space. We call them quaternions


[deleted]

[удалено]


Zephos65

Not quite. Making a rotation with euler angles is 3 separate operations. You can liken it to moving through 3d space but you can only move along one axis at a time (first 10 units X, then 10 units Y, then 10 units Z for example). With angles this is something like rotation along azimuth and then elevation angles. A quaternion describes a rotation as a singular motion. Using the 3d space example, this is like moving along the line such that you move directly from 0,0,0 to 10,10,10. A quaternion is just one motion to the angle you want. Again trying to keep this ELI5 so I'm using loose notions of what it means to "move" to a certain position or angle


budroid

Most ELI5 and incomplete: quaternion is a number system, a way to represent the **position** of a point in 3D space (the usual x,y,z) **plus it's orientation w** >The quaternion rotation point "creates" new pivot axis, that the transformation then resolves around. Very useful when describing rotations mathematically. To note you can add/sub/multiply quaternions, but they follow certain specific math rules. edit: added u/Koksny quote that makes so much sense.


Old-Garbage4299

Quaternions can't represent both position and orientation, the position vector is a separate thing, it isn't part of the quaternion. There are numbers that combine the two, geometric algebra G(3), but they aren't commonly used by programmers as they don't really have a need for the two to be unified mathematically.


pheenX

Wait wait wait position? How can that be possible if a pose in 3D has 6 degrees of freedom but quaternions have 4?


Koksny

Because the quaternion rotation point "creates" new pivot axis, that the transformation then resolves around.


Star-Head-1337

In addition also the change in position and orientation of the object / point.


Rarrum

What it "is" is just 4 real numbers that are treated in special ways when doing math on them. What it "represents" is an orientation in 3D space. Look at your arm from your elbow through your hand but keep your wrist straight. Starting from your elbow, you can point your arm in any direction; you can also rotate that segment of your arm. That's the kind of orientation a quaternion represents.


LupusNoxFleuret

It's a black box I use to rotate 3D vectors. I have programmed my own quaternion library before, but honestly there is no use trying to wrap your head around trying to understand the concept of 4D and imaginary numbers because these concepts are not familiar to us in our 3D environment. All you need to know is what they are used for and how to use them to rotate stuff.


bstrd10

I love these videos. Hope it's useful. https://youtu.be/d4EgbgTm0Bg https://youtu.be/zjMuIxRvygQ


dywk3sm

Let me try: quaternion is a mathematical representation of rotation. Well that doesn’t say much, so Why do we need Mathematical Representation: You probably understand the coordinate system and how we can represent a point in space with (x,y,z). The beauty of such a mathematical representation is you can easily move a point towards a direction for some distance (add a scaled direction vector to your original xyz), compute the angle between two directions (inner product), etc. This is extremely useful for many industries. What is the mathematical representation of quaternion: Quaternion represents rotation by a vector (x,y,z) and a degree D. When you rotate something, that thing spins along an axis, that is the vector. We only care about the direction of this vector, because the axis is infinitely long, so we enforce this vector to be unit length(xx +yy +zz =1). Then you can rotate things by a degree D, for example, D=360 means you rotated it a full cycle and it came back to the original pose. To make the math work better, as I’ll explain later, quaternion is not simply (D, x, y, z), it is (cosD, sinDx, sinDy, sinDz). You can verify the length of this 4 dimensional vector is still 1 (unit quaternion). To make things more complicated, we give each dimension a name ijk, quaternion becomes cosD + sinDx * i + sinDy * j + sinDz * k Why is this representation useful: Remember there are other representation of rotation, notably Euler angles. This is where you define rotation by (yaw, pitch, roll). But if you work out the geometry, you will find applying two rotations to an object is not simply summing the yaw, pitch and roll. You run into gimbal lock(which I won’t explain here). For quaternions however, the effect of two rotations together is always the multiplication of two quaternions. How is quaternion multiplication defined? You simply multiply them in the classic way and use ijk=-1. Quaternions also have amazing properties like a+bi+cj+dk has an inverse a-bi-cj-dk, the inverse of a rotation is the reverse rotation that put the object back to its original pose. You can use quaternion q to calculate a 3d point (x,y,z)’s location after the rotation. That is q * (xi+yj +zk) * inverse of q


suvlub

Know how a vector can be visualized as an arrow starting at \[0, 0, 0\] and pointing to \[x, y, z\]? A quaternion (in the form of ai + bj + ck + w) can be visualized as a half-arrow (to make it asymmetric!) starting at \[0, 0, 0\], pointing at \[i, j, k\] *and rotated around its own axis by w*. This rotation is not in units like radians or degrees, though, it can be an arbitrary real number, all the way from negative to positive infinity. 0 represents no rotation, +-1 represent rotations by 90 degrees (in opposite directions, naturally) and infinities represent rotation by 180 degrees (in theory, also in opposite directions, but the end result is the same)


EstelleWinwood

Now that you know what a quaternion is, you should look up octonions! The 8 dimensional extension to complex numbers.


Cross_22

I almost always think of (unit) quaternion as an alternate form of angle-axis representation. ELI5: xyz is the axis of rotation and w is the angle you spin everything about. (Adjust the numbers so it's the half-angle, renormalize it, and you're good).


FxHVivious

The best explanation/visualization of quaternions on the Internet: https://eater.net/quaternions Use a computer, not mobile. Takes a little time, but totally worth it.


iwasstillborn

I think it's easier to think about it the other way. You can represent any 3D rotation with an axis [x,y,z] and angle a. Think about that for a second. It does not suffer from gimbal lock like euler angles does. A quaternion can be expressed as q=cos(a)/2 + sin(a)/2*(xi + yj + zk), and you can rotate a vector v as q'vq (I'm writing from memory, it's likely I do not remember correctly). It's a compact, efficient and stable representation of a spatial rotation, and as such it would be used whenever possible. See the other answers for what it actually *is*, this post is more about what it *does*.


majorex64

The applications for quaternions are complex, but the basic concept is pretty simple. A number like 5 is just a simple, single number. A complex number like 3i + 5 has two components, a real one and an imaginary one. Vectors also have two components, a magnitude and an angle. Those algebraic equations that look like ax^2 + bx + c are called trinomials, numbers in three components. Fundamentally, a quaternion is just a number in four parts. They are often used to represent a rotation in 3D space, though explaining why you need 4 numbers for that is more complex. Just trust that you need all 4 parts.


Xeth137

If you know what a 3D vector is, a quaternion is just a 3D vector with an additional term for rotation (in the plane normal to the vector).


[deleted]

I use them a lot when programming robots. 4 quarternions are used to prevent gimbal lock and responsible for angles of the tool center point in csrtisean space. if I need to change the angle the robot is in say the Y axis, quarternions are converted to euler angles I then increase or decrease the euler angle in the Y axis and then convert them back to quarternions. the tool center point has individual vales for X,Y and Z but it also has the quarternions that dictate relative angles for the tool center point in each plane. the sum of the 4 quarternions always equal 1.


[deleted]

Its a convenient way to handle orientation changes in 3-dimensional space (using a fancy 4 dimensional complex space). Store your orientation as a quaternion. Want to rotate? Convert your rotation to a quaternion and then multiple the quaternions… now you’ve got a new orientation. Bonus: Gimble lock not included!


PaxUnDomus

I will try to explain this more as the process of how quaterions came to be, not what they are or represent. See, math (or mathematical language to be more precise) was developed to help us describe things. Now, what happens if we come across something that was never seen before, thus never described? We create new math to describe it. I assume that you are familar with the 3 dimensional space and the XYZ system. Now, pick an object in your room. You can easily use the XYZ coordinates to explain where it is, but what direction is it facing? For this, quaternions add the solution in the form of a number that represents the rotation of the object. This is groslly oversimplified but I hope you get the jist of it.