How to think about Quaternions without your brain exploding

  Рет қаралды 29,726

Alex Rose

Alex Rose

Күн бұрын

Just a little description about Quaternions to use in your game development. Should be useful for Unreal Engine and any other Quaternion using engine (or honestly, any rotator engine), but specifically I used Unity's orientation system and notation for my examples here

Пікірлер: 77
@susanollington5257
@susanollington5257 Жыл бұрын
Haven’t really needed to use this before because I’ve been in 2D, but this was fascinating and a good explanation of something I’ve always heard people explain as “something you don’t really need to understand yet”
@AlexRoseGames
@AlexRoseGames Жыл бұрын
I still find use for quaternions in 2d. They're nice because they can always find the shortest angle. say you're at 270 degrees and you want to get to 30 degrees, the best way to go is to translate from 270 to 360/0 through to 30 (60 degrees), but if you lerped you would go 240 degrees in the opposite direction instead. you can fix this with modulos but sometimes it's easier to just use quaternions, especially if you're moving things around by position too. like you want an eye that spins but the iris follows you
@MattRix
@MattRix Жыл бұрын
@@AlexRoseGames Worth noting that Unity users can also use Mathf.DeltaAngle() for that specific use case.
@yijieding5610
@yijieding5610 9 ай бұрын
using cub to do quaternion explanation is just genius. many thanks
@angeldude101
@angeldude101 Жыл бұрын
Quaternions really are very natural for representing rotations when they're not being unnecessarily obfuscated. The three "imaginary" -bivector- terms are pretty understandable; they're the 3 basis axes / basis planes and all of them do 180° rotations (with 2-sided rotations). The scalar then has absolutely nothing to do with 4D space and _everything_ to do with _doing absolutely nothing._ A quaternion is just a weighted sum of rotations around each of the three basis axes plus the action of doing nothing. I will briefly mention the existence of "dual quaternions," which let you encode the transformation as a multiplication just like the rotations, and then you can just translate from the object to the origin, apply a rotation, and then translate back as TRT¯¹ (assuming you're composing from right to left), and the whole thing will perform a rotation around the origin of the object in the same plane as R. It's basically what you did manually with addition, but more composable.
@behrampatel3563
@behrampatel3563 7 ай бұрын
Thanks for adding your valuable insight. Do you have a page or blog I can follow you on. Cheers, b
@midniteoilsoftware
@midniteoilsoftware Жыл бұрын
I’ve been using Quaternion.Identity and Quaternion.LookRotation for a couple years but but never understood how they worked until watching your video. Thanks for this!
@behrampatel3563
@behrampatel3563 7 ай бұрын
This is a very unique take on the path to understand what quaternions are. It helps a lot . Thank you
@darrennew8211
@darrennew8211 5 ай бұрын
This is a very clever presentation that does a great job of making the non-commutitive nature of Q's intuitive.
@iraf27
@iraf27 22 күн бұрын
Thanks a lot! maybe in a few hours i can understand the concept of quaternion, if my brain don't explode before it
@DanielJKlug
@DanielJKlug Жыл бұрын
This is super helpful as a visualization tool. Thank you!
@zoop391
@zoop391 10 ай бұрын
Just what I needed :) I've been struggling to understand quaternions mathematically, so just to understand how to use the tool is good enough for me for now.
@MattRix
@MattRix Жыл бұрын
This is great! I find that most of the time when I use quaternions I'm thinking of them in the way you talked about right at the end, either as a Quaternion.LookRotation (forward vector, up vector) or as an angle around an axis vector with Quaternion.AngleAxis (angle, axis vector), which works like a shish kebab as you described.
@breakdancerQ
@breakdancerQ 8 ай бұрын
This is a very good tip on how to visualise these damn things! Not there yet but this certainly helps a ton!
@botalex4845
@botalex4845 Жыл бұрын
I cannot believe that a 10-minute video, that was made with paint and a Rubix cube explained Quaternions better than 3blue1grey and their fancy graphics. Thank you!
@minhajsixbyte
@minhajsixbyte 11 ай бұрын
one is mathematician's explanation, the other is programmer's explanation.
@angeldude101
@angeldude101 9 ай бұрын
​@@minhajsixbyte Ya, 3B1B's explanation is the programmer's explanation, and this is the mathematician's explanation.
@gameuniverse941
@gameuniverse941 8 ай бұрын
Rubik’s*
@pronounjow
@pronounjow 7 ай бұрын
​@@angeldude101Isn't it the other way around?
@angeldude101
@angeldude101 7 ай бұрын
@@pronounjow Nope. A programmer would care mostly about how to implement something and use it. From the perspective of lists of numbers, quaternions are 4D and have crazy multiplication table that you just need to write down in your code and then forget about it. A mathematician should actually care about the meaning behind the symbols and the relationships between them. Basically, as a programmer, quaternions are a compact but arcane data structure that happens to be good at rotating vectors. As a mathematician, quaternions _are_ rotations, and the multiplication table is just a reflection of the physical rotations that quaternions translate into algebra.
@michaeldiaz4285
@michaeldiaz4285 Жыл бұрын
Solid explanations and examples
@ModerateDev
@ModerateDev 4 ай бұрын
The end of this video was enlightening I thank you !
@user-dd9is6iy9m
@user-dd9is6iy9m Жыл бұрын
This was pretty helpful! As a guy who hates dealing with Quaternions - thank you.
@AlexRoseGames
@AlexRoseGames Жыл бұрын
no problem! whenever I looked for how to deal with quaternions it was always like "now imagine this 4th dimensional sphere" and I was just like... okay this makes zero intuitive sense to me
@TrueBlur
@TrueBlur Жыл бұрын
This helped me get through a problem on the last day of my internship! Thanks!
@AlexRoseGames
@AlexRoseGames Жыл бұрын
haha, glad I could help, congrats
@_tioanon
@_tioanon 10 ай бұрын
That's abbsolutely brilliant. Thank you!
@AlexRoseGames
@AlexRoseGames 10 ай бұрын
No problem. Enjoy!
@mactyler
@mactyler Жыл бұрын
Dude oh my god, thank you so much for this, first time its ever clicked for me!
@AlexRoseGames
@AlexRoseGames Жыл бұрын
haha glad I could help
@RaphpowerSGSUModding
@RaphpowerSGSUModding Жыл бұрын
When you make a sonic fan-game and your character need to have a tube based movement system this is perfect
@fuseteam
@fuseteam 6 ай бұрын
instructions unclear solved a rubik's cube with quaternions
@Ar3Ar3
@Ar3Ar3 Жыл бұрын
You just made Quaternions easy for me.
@carstenschluter3446
@carstenschluter3446 25 күн бұрын
legend
@peggycarter6515
@peggycarter6515 Ай бұрын
5:21 şiş kebap dediği yerde koptum 😅güzel betimleme olmuş
@AlexRoseGames
@AlexRoseGames Ай бұрын
haha, teşekkürler
@cristianjuarez1086
@cristianjuarez1086 Жыл бұрын
Excellento
@spoopyradicalsnake
@spoopyradicalsnake 11 ай бұрын
to really understand quaternions you need : direction cosine matrix, euler rotation matrix --> rodrigues rotation formula, finally quaternions. when you use euler rotation matrix, you will see why we need quaternions really bad
@PaulSpeed42
@PaulSpeed42 Жыл бұрын
In case it's helpful to anyone stuck using 3x3 rotation matrices, for everything in this video Quaternion can be replaced with 3x3 rotation matrix and its all still true. They are interchangeable in this conversation. But I guess "quaternion" is easier to say than "3D rotation" all the time.
@FranziskanerFranz
@FranziskanerFranz Жыл бұрын
Not quite interchangeable, Euler angles suffer from the gimble lock problem, which quaternions inherently overcome.
@PaulSpeed42
@PaulSpeed42 Жыл бұрын
@@FranziskanerFranz that's why I never mentioned Euler angles.
@FranziskanerFranz
@FranziskanerFranz Жыл бұрын
@@PaulSpeed42 ah that's right, my bad. As soon as I read matrix I jumped to euler angles, simply because I never wrote down quaternions as matrix.
@angeldude101
@angeldude101 9 ай бұрын
Rotation matrices are not rotations, but rather _orientations._ They don't distinguish between clockwise and counterclockwise. Quaternions meanwhile are _rotations,_ with 2 distinct quaternions for every orientation, one which travels clockwise from a given perspective, and one which travels counterclockwise from that perspective. Also regardless of rounding errors, every quaternion is a scaled copy of a unit rotation, where as matrices, with 5 extra redundant components can be much easier to accidentally turn a normalized orientation into something that definitely _isn't_ an orientation.
@danibiyarslanov
@danibiyarslanov 9 ай бұрын
i like the title
@AlexRoseGames
@AlexRoseGames 9 ай бұрын
thankyou, i like your comment
@petethechin
@petethechin Жыл бұрын
Im still confused.....
@andrey730
@andrey730 6 ай бұрын
Example at 9:17 helps understanding how quaternions inverses can be used but I'd probably just add to pos_A some offset_vector multiplied by transform_matrix_A. Or it can even be just 1 basis vector from transform_matrix_A multiplied by offset magnitude (in case if we're sure about the axis). Unsure though how much quaternions more efficient than matrix multiplication. Multiplying matrix by vector typically takes 9 multiplications and 3 adds, don't know about the quats. PS Love the shish kebab metaphor 😂
@AlexRoseGames
@AlexRoseGames 6 ай бұрын
yeah, the example was there to demonstrate how you can operate on inverses with a simple example, but in reality I would do the same as you. though there are more complicated scenarios where I would use the method I described
@gasparliboreiro4572
@gasparliboreiro4572 6 ай бұрын
can someone explain me how to interpretate the components in a cuaternion? like a + ib + jc + kd i can only think about a, b, c, d as a 4d vector, like (a, b, c, d), how does that ends up being a rotation?
@AlexRoseGames
@AlexRoseGames 6 ай бұрын
it's not something that's easily human parseable. if pitch is a, yaw is b and roll is c, quaternion x y z and w are: x = sin(c/2) * cos(a/2) * cos(b/2) - cos(c/2) * sin(a/2) * sin(b/2) y = cos(c/2) * sin(a/2) * cos(b/2) + sin(c/2) * cos(a/2) * sin(b/2) z = cos(c/2) * cos(a/2) * sin(b/2) - sin(c/2) * sin(a/2) * cos(b/2) w = cos(c/2) * cos(a/2) * cos(b/2) + sin(c/2) * sin(a/2) * sin(b/2)
@zanagi
@zanagi 4 ай бұрын
Really cool to use rubik cube
@AlexRoseGames
@AlexRoseGames 4 ай бұрын
thankyou
@Jay-kb7if
@Jay-kb7if 9 ай бұрын
it's frustrating that it's all about the gimbal lock. People need to start thinking about whether they can rotate at points other than the x y or z axis with a gimbal.
@thtdrgnmn
@thtdrgnmn Ай бұрын
Me want know how make quaternion relative to other quaternion
@AlexRoseGames
@AlexRoseGames Ай бұрын
quatBRelativeToA = quatB * inverse(quatA)
@AlexRoseGames
@AlexRoseGames Ай бұрын
e g let's say you spun your cube to configuration A: +z then +x then +x the inverse of this (to get back to a solved rubiks cube) is -x then -x then -z let's say your new configuration B is +z +x + x +y. I think you will agree that relative to A you would expect B to be simply +y so let's see, inverse (A) = -x -x -z, B is +z +x +x +y, so B * inverse(A) does all of the righthand instructions then all of the left so -x -x -z +z +x +x +y as you can see from the middle, the -z and +z cancel, then the two pairs of x's cancel, leaving just +y. so we can see in this example the formula works
@thtdrgnmn
@thtdrgnmn Ай бұрын
@@AlexRoseGames this single comment just helped me understand quaternions to a higher degree
@radishmonster2760
@radishmonster2760 Жыл бұрын
Are you related to mike rose?
@AlexRoseGames
@AlexRoseGames Жыл бұрын
yes
@fakeit6339
@fakeit6339 Жыл бұрын
that rubiks website or game please
@AlexRoseGames
@AlexRoseGames Жыл бұрын
just google rubiks online, I went on the first link
@timlindberg3833
@timlindberg3833 4 ай бұрын
A vector also has a magnitude 🤓
@AlexRoseGames
@AlexRoseGames 4 ай бұрын
in this case I was using the word direction a bit colloquially for non layman, as in like "the pub is 5 miles north east of here". more technically I meant a displacement (aka a unit vector direction and its magnitude) not just a normalised direction. the point anyway was to distinguish that a vector does not have a preferred origin, it describes a transform that takes you from any arbitrary point to another calculable point based on that transformation applied in a specific frame
@no3339
@no3339 Жыл бұрын
Geometric algebra >>
@zeusifer007
@zeusifer007 Жыл бұрын
tNice tutorials software
@josephrussell1419
@josephrussell1419 3 ай бұрын
You are comparing how multiplication works in quaternions with how addition works in 3D vectors. But the quaternions still also have addition with an additive identity and additive inverses and behave just like 4D vectors in that sense. You saying that quaternions have multiplication "instead" of addition will make people feel they understand things when they'll just get horribly confused if they delve any deeper. Also, the two systems do not have different notions of an "origin". You are confusing the idea of an origin in the sense of (0,0,0) or (0,0,0,0), i.e., a coordinate system, with the idea of identity with respect to some transformation. When we say that one times two equals two, and two times 1/2 equals one, we don't call "one" the "origin". It's the same in any higher-dimensional number system. I like the Rubik's Cube demo though.
@critical_always
@critical_always 2 ай бұрын
Why have all the kiddies started talking in that weird exaggerated wayje
@AlexRoseGames
@AlexRoseGames 2 ай бұрын
I'm 32, this is how I speak in lectures
@KaoukabiJaouad
@KaoukabiJaouad 10 ай бұрын
you didn't explained quaternions at all, you explained basic rotations, and transformations, the whole point of quaternions is avoid gimbal lock, so it never ever happen, you introduced your videos with that premise and the whole time you didn't tackle the subject.
@AlexRoseGames
@AlexRoseGames 10 ай бұрын
the video is called how to *think about* quaternions, the description states it's to use in your game engine. in the first 25 seconds I said I wouldn't be talking about the mathematical aspect of quaternions. this video is aimed at people who need to use quaternions in their development. if you want a mathematical description of quaternions I recommend 3blue1brown's video, it should be the top hit on youtube when you search up quaternions
@KaoukabiJaouad
@KaoukabiJaouad 10 ай бұрын
@@AlexRoseGames you made a mistake, just change the video description, and put mathematical rotations applied to games, if you put quaternions there, you have to talk about what makes quaternions, quaternions, you introduced the video on gimbal lock and the need for quaternions and you followed on rotations being not commutative the order is important(that algebra 101), and you stretched that point the whole video, your title is a clickbait, people are so dumb look at the comment below this one, one guy thought you explained quaternions better than 3blue1brown.
@AlexRoseGames
@AlexRoseGames 8 ай бұрын
@@KaoukabiJaouad you are just not the target audience for this video. 3blue1brown's video is great, the video you want to watch already exists. you are irrationally mad that people here found this video useful, they're exactly whom I made it for. developers applying quaternions to game development or robotics don't need to know about complex spaces, they need an intuitive way to think about applying them. if you didn't listen to the intro or read the description, that's a you problem not a me problem
@Oxygenationatom
@Oxygenationatom Ай бұрын
@@AlexRoseGamesim so sorry that you have to deal with people like this
@jr8209
@jr8209 Жыл бұрын
The puzzle cube adds unnecessary complexity.
Godot's Quaternion Variant is Beautiful (and misunderstood)
18:52
Fantastic Quaternions - Numberphile
12:25
Numberphile
Рет қаралды 1 МЛН
Useful Gadget for Smart Parents 🌟
00:29
Meow-some! Reacts
Рет қаралды 10 МЛН
Зу-зу Күлпәш. Стоп. (1-бөлім)
52:33
ASTANATV Movie
Рет қаралды 863 М.
Teenagers Show Kindness by Repairing Grandmother's Old Fence #shorts
00:37
Fabiosa Best Lifehacks
Рет қаралды 36 МЛН
How to Use Quaternions
14:20
Positive Altitude
Рет қаралды 7 М.
Giving Personality to Procedural Animations using Math
15:30
t3ssel8r
Рет қаралды 2,3 МЛН
Euler vs Quaternion - What's the difference?
8:49
Class Outside
Рет қаралды 29 М.
Quaternions EXPLAINED Briefly
17:51
Mathoma
Рет қаралды 299 М.
Quaternions
39:07
UC Davis Academics
Рет қаралды 168 М.
a quaternion version of Euler's formula
20:33
Michael Penn
Рет қаралды 71 М.
17. Введение в кватернионы
19:58
ЦИТМ Экспонента
Рет қаралды 29 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 670 М.
How Ray Tracing (Modern CGI) Works And How To Do It 600x Faster
32:06
Josh's Channel
Рет қаралды 538 М.
skibidi toilet 73 (full episode)
9:41
DaFuq!?Boom!
Рет қаралды 23 МЛН
Which Animal Is The Best At Supervising The Thief? 🤔️
0:24
BigSchool
Рет қаралды 17 МЛН
#pomni #angela
0:13
My Angela2
Рет қаралды 10 МЛН