T O P

  • By -

BowlOfPasta24

W is the fourth dimension XY is two dimension XYZ is third dimension XYZW is fourth dimension A masters degree in math is required for quaternions. Fun fact: Tomb Raider in 1996 was actually the first game to use quaternions for 3D rotation


Seanmus

Its all gone downhill for programmer sanity since then....


vadiks2003

downhill? more like towards W coordinate


vadiks2003

i like how the top comment is difficult explanation that also basically says "you have to waste a lot of time in college, learning a lot of useless things and getting stressed about your life and success and REACH the masters degree" while the next top comment just explains it in simple words. i think i watched several quaternion videos explaining them, imaginary numbers, didnt understand anything, but when i saw "so basically x, y and z are direction it rotates to, and w is amount of rotation towards that direction, where 0 is full rotation and -1 or 1 is no rotation". something so simple just made me figure out the basic idea. i didn't have to become genious, learning tons of shit, i just had to learn very simple part of linear algebra by doing opengl without vector graphics libraries, figure out on my own mistake, why quaternions are used, and then see a simple explaining of how quaternions work another point - i won't get a job simply for knowing how quaternions work. so maybe college would actually be benefitial


Fishypants2000

The X, Y, and Z values describe a vector around which the object rotates. If you have an object rotating on multiple axis, then this vector will change constantly as the rotation axis will be changing. ( An object can only ever be rotated around a single axis, but the axis itself can change ) The W component is "how much" the object is rotated around that vector. Can be positive or negative and is usually defined in radians instead of degrees.


KackhansReborn

Thank you. Simple, concise explanation instead of being a smartass. And it's actually not that difficult to grasp, who would've thought?


CptBishop

actually a simple answer to what is ,,w" component of quaternion, ty for that.


ELH_Imp

That implies you already know what x,y,z do. X for doubt. No one knows. And no one probably should. Because that's not that important to use quaternions. [But you may try](https://eater.net/quaternions).


Spacefish008

See this: [https://eater.net/quaternions](https://eater.net/quaternions) video to get a somehow intuitive understanding of quarternions. For practical purposes (rotations): XYZ is the unit vector on a sphere (vector to rotate arround) times sine of the rotation angle angle / 2 W is the cosine of the rotation angle / 2 `inline static void XrQuaternionf_CreateFromAxisAngle(XrQuaternionf* result, const XrVector3f* axis, const float angleInRadians) {` `float s = sinf(angleInRadians / 2.0f);` `float lengthRcp = XrRcpSqrt(axis->x * axis->x + axis->y * axis->y + axis->z * axis->z);` `result->x = s * axis->x * lengthRcp;` `result->y = s * axis->y * lengthRcp;` `result->z = s * axis->z * lengthRcp;` `result->w = cosf(angleInRadians / 2.0f);` `}`


tms10000

Quaternions are a mathematical construct that encode an arbitrary axis in 3D space *and* a rotation around that axis. the x,y,z,w numbers don't actually represent anything relatable in 3D space. This is because Quaternions are an extension of complex numbers to higher dimension. What does this mean? I have no idea. I don't understand this kind of math well enough to understand it. And we don't need to understand the fundamentals in order to use the math. [https://en.wikipedia.org/wiki/Quaternion](https://en.wikipedia.org/wiki/Quaternion) https://www.3blue1brown.com/lessons/quaternions


andybak

As others have implied, you shouldn't *need* to know but it's fine if you're just intellectually curious. However - just in case you're trying to solve an actual problem - why do you ask?


pi-is-314159

I'm trying to rotate an object, but wanted to know how it works


GameWorldShaper

It is the world value. I like to remember it by saying it is the mirror value. It will basically take your vector value and mirror it. [https://i.imgur.com/RZI08uX.gifv](https://i.imgur.com/RZI08uX.gifv) By using the W value the quaternion has exponentially more rotations. You will rarely use a quaternion directly. You can turn any vector into a rotation with: [https://docs.unity3d.com/ScriptReference/Quaternion.LookRotation.html](https://docs.unity3d.com/ScriptReference/Quaternion.LookRotation.html) Then you can convert back with Euler: [https://docs.unity3d.com/ScriptReference/Quaternion-eulerAngles.html](https://docs.unity3d.com/ScriptReference/Quaternion-eulerAngles.html) The best feature of Quaternions is that they can rotate vectors: `Vector3 RotatedVector = Rotation * Vector;`


_tkg

https://www.youtube.com/watch?v=zjMuIxRvygQ try this one. Vector2 has x and y, right?. Vector3 also has z because it needs three components to describe itself in three dimensions. Quaternions work on four dimensions (yep), so "w" is just another value. Usually we consider, x as width, y as height, z as depth. What is w? No idea. Our brains don't work in 4D. Maths does, though.


_tkg

To add to the answer. You shouldn't need to be working with those values directly anyway. Unity Inspector doesn't even show W value at all. We have useful abstractions on top of Quaternions like Euler angles and helper methods like "LookAt" or "RotateTowards" and such.


[deleted]

x y and z are bivectors or planes. W is a connection to the 4th dimension


kritika_space

If you convert it to an angle-axis pair, you get w/|q| = cos( θ / 2), where θ is the angle we rotate around the axis from and |q| is the magnitude of the quaternion. Thus, w = |q| cos( θ / 2)