AHHHHHH I finally understand quaternions!! XDD :DD

I always thought they were neat fun thing in abstract algebra and a neat but arbitrary way of representing rotations with unnecessarily extra numbers.

If someone had just said to me this sentence I would have seen how insanely perfect they are!! :D

As rotations, the i/j/k coefficients are the x/y/z components of the axis-of-rotation vector, and the fourth lone number is the amount of the rotation in radians!

@codepuppy teach me! I'm playing with an IMU currently.

@dannyboy :D!

Well it's actually a little bit different than I said there; I corrected myself a few posts down ^^'

But you know how in a given coordinate system, a 3D vector is basically just 3 numbers?

Well in a coordinate system, a quaternion is basically a group of four numbers! Usually called a,b,c,d

(0/(n-1))

Now a bit of background: all rotations can be thought of as rotations around an axis and an amount/angle of rotation around it, right? :>

You can even take *as many rotations as you like* about *different* axes and combine them together into one probably-bizarre rotation about a single very particular axis and a single very particular angle!

That's https://en.wikipedia.org/wiki/Euler%27s_rotation_theorem :>

(1/(n-1))

To store a 3D axis and an angle, that would take four numbers, right? Three for the axis vector and one for the degrees/radians :>

Quaternions are simply a way of storing those four numbers in a way that's very nice because in quaternion form, the expensive trig functions are precomputed/cached!

And all you need to do to rotate a vector by a quaternion is just multiplication and addition! :D

(A lot like a rotation matrix! But a quaternion only takes 4 numbers not 9!)

(2/(n-1))

So here are the formulas for that!

For quaternion = (a,b,c,d)

a = cos(θ/2)

b = x * sin(θ/2)

c = y * sin(θ/2)

d = z * sin(θ/2)

Where x/y/z are the coordinates of the axis of rotation vector and θ is the amount/angle of rotation in radians :D

(3/(n-1))

The other important formulas are how to multiply quaternions, which like for matrices, corresponds to composing transforms (a * b = rotation by b then by a), and the formula for actually transforming a vector given its x/y/z, but I'll let you look those up on your own since they're a lot to put here XD'

(I might add them later though, for reference ^^' )

https://en.wikipedia.org/wiki/Euler%E2%80%93Rodrigues_formula

https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation

https://en.wikipedia.org/wiki/Quaternion

:>

(4/(n-1))

The important interpretation/applications of quaternions for us here is that:

A quaternion represents a single rotation in 3D space out of all possible rotations!

Yaw/pitch/roll and Euler x/y/z angles and Axis-and-Amount and Quaternions are all just ways of representing the exact same thing: any possible rotation of an object (or point or set of points) in 3D space :>

(5/(n-1))

@dannyboy *I know right!* X'D

The main page has been overrun with abstract algebra and ignores the other connections to quaternions! (Including this spatial one, which is *how/why quaternions were discovered in the first place!!* XD )

Puppy Pi@codepuppy@mathstodon.xyz@dannyboy

If any of that wasn't clear or you've got any questions about that or the background stuff, feel free to ask! :D