Godot's Quaternion Variant is Beautiful (and misunderstood)

Поделиться
HTML-код
  • Опубликовано: 17 дек 2024

Комментарии • 91

  • @SDGGames
    @SDGGames  Год назад +36

    Quick Corrections:
    5:43 I was referring to the commutative property (I misspoke and said cumulative.) You can google "associative, commutative, and distributive" for more details on "basic" algebraic properties. But, yeah, some laws can break in higher dimensions.

    • @felicaamiko
      @felicaamiko 6 месяцев назад

      you spelled gimbal wrong sometimes, also in 16:19 you spelled quaternion with an extra n

    • @pruthweeshasalian3688
      @pruthweeshasalian3688 6 месяцев назад +1

      @@felicaamiko "quanternion" is also how he pronounces it throughout the video

  • @dv_interval42
    @dv_interval42 6 месяцев назад +30

    Goddamnit. The gatekeepers have kept such a crazy simple concept behind "bro too complicated" doors.Thank you so much for clarifying this!

    • @NihongoWakannai
      @NihongoWakannai 3 месяца назад +1

      Bro not everything is gatekeeping just because people aren't giving you a personal lesson on mathematics.

    • @imadetheuniverse4fun
      @imadetheuniverse4fun 18 дней назад

      imagine having a mind where you think everything's a conspiracy and that people are out to keep you down instead of, maybe, just maybe, you didn't put enough effort in to understanding a little bit of math. wow. just wow.

  • @fnkycoldmadeanr
    @fnkycoldmadeanr Год назад +38

    "Genius is making complex topics simple"
    Thanks for making quaternions finally click for me 🤯

    • @jedikoops
      @jedikoops 6 месяцев назад +1

      ok but what if ur not a genius...

  • @red3tango
    @red3tango Год назад +23

    Very well done explaining Quaternions, so wish I saw this video years ago. Would like to see a video with this type of explanation of Transform3D/Basis too. I know many solutions (and other engines) use Quaternions, however, Godot uses T3D/Basis "under the hood"; the inspector Euler angles are just for ease-of-viewing, and the Quaternion methods are wrappers that interact with the underlying T3D/Basis variant.

    • @SDGGames
      @SDGGames  Год назад +7

      Good catch! I'm working on a general Variant video now. I'm not sure if anything else will need to break out like Quaternions did, but I'll definitely be looking into T3Ds in more detail this week.

  • @GonziHere
    @GonziHere Год назад +9

    a) really great tutorial. Saved for linking to others when needed.
    b) one of the great results of Quaternions is that you can lerp from one random rotation to another and it won't do something weird as it would with eulers.

  • @FigmentVFX
    @FigmentVFX 12 дней назад

    Thank You! I have been trying to wrap my head around quats for ages. This finally made sense. +100 knowledge!

  • @yvanvan3729
    @yvanvan3729 Год назад +4

    Great explanations, awesome tutorial.
    And icing on the cake, sources available on git !
    Thank you for making this video.
    Have a wonderful day.

  • @kmjohnny
    @kmjohnny 14 дней назад

    This gives me a different perspective on quaternions - that I really appreciate.

  • @bruno-brant
    @bruno-brant 28 дней назад

    First video that gives the intuition of quaternion real fast.

  • @awyeagames
    @awyeagames 10 месяцев назад +3

    Lol chatgpt being a waste of time is to be expected.
    Excellent video! I finally understood how to use quaternions in godot. Thank you!

  • @indoorraccoon4450
    @indoorraccoon4450 11 месяцев назад

    thank you so much! I loved every minute of it. Was trying at this for hours trying to find out how quaternions work in godot so your source code really helps

  • @weeknight74
    @weeknight74 9 месяцев назад

    Thanks for the video! I had been stuck on 3d rotations in Godot for a while and this video helped me understand the why my rotations weren't working as expected. Getting down to the physics of it was super useful.

  • @briancunningham4491
    @briancunningham4491 6 месяцев назад

    Excellent video, thank you for taking the time to put this all together!

  • @cherico94
    @cherico94 Год назад

    you are awesome! thank you so much for making this. I remember trying to understand quaternions so many times in the past and just give up and just use it cuz it "just works". You made it so easy for me to visualize it and understand it in under 20 minutes!

  • @xx0124xx
    @xx0124xx 6 месяцев назад

    Okay well, I haven’t even watched the video yet but that story telling at the beginning was INCREDIBLE

  • @dubfather521
    @dubfather521 Месяц назад

    Yeah you finally were able to make me understand. All other explanations tried to explain quats as some four dimensional object. its just a vector and a rotation value

  • @komronyusufjonov4022
    @komronyusufjonov4022 Год назад +2

    Well thats the best explanation of quaternions )
    Thanks a lot )

  • @MajikayoGames
    @MajikayoGames 11 месяцев назад

    Great vid. Good explanation that helped me understand gimbal lock and usage of quaternions in practice. You're right the 4D stuff about how they work is quite involved, will go watch the 3B1B vids if I ever have a need to understand their implementation.

  • @xananacs
    @xananacs 5 месяцев назад

    Excellent work and good job on the visual explanation

  • @RafaelRodrigues-jq6uc
    @RafaelRodrigues-jq6uc 11 месяцев назад

    dude this is the best tutorial ive seen thank you so much i can understand now!

  • @AnnoyingNoisesProductions
    @AnnoyingNoisesProductions 7 месяцев назад

    Hey, thanks a lot! 👍 This really helped me get the random spread on my projectiles working.

  • @jiaxihe
    @jiaxihe 2 месяца назад

    Thank you so much!! I really need it

  • @Learning_For_Godot
    @Learning_For_Godot Год назад +2

    I love your channel so much!! i just found it today and it's amazing

    • @SDGGames
      @SDGGames  Год назад +1

      Ooh, yeah. My script said communitive, but those long C words all jumble together sometimes!

  • @wulfrickwille3871
    @wulfrickwille3871 Год назад

    Good vid! Also looking forward to the Variant video :)

  • @Zurpanik
    @Zurpanik Год назад

    Excellent video and work! Fantastic reference! Thank you!

  • @kurtisgibson2929
    @kurtisgibson2929 25 дней назад

    you can also use if is_equal_approx(0, interpolated_quat.angle_to(quat_box.quaternion)): at line 78 in quinternion_demo it will check for mild over and under shoot

    • @SDGGames
      @SDGGames  24 дня назад

      That's a good trick, thanks!

  • @dbatdev
    @dbatdev 5 месяцев назад

    a beast of a vid. thank you!

  • @FuzzballStudios
    @FuzzballStudios Год назад

    How was I not using this before? Thank you so much!

  • @DragnarosDonevan
    @DragnarosDonevan 6 месяцев назад

    Extremly helpful! thank you. this will save me a lot of frustration

  • @jorgedavidcoronadoalonso
    @jorgedavidcoronadoalonso 11 месяцев назад +1

    Wow, you have a new follower, thank you for the explanation, I was not understanding why my rotation sometimes didn't work. I was searching a local rotation function 😂.

  • @JoLo-vx1nb
    @JoLo-vx1nb 11 месяцев назад +1

    Nice presentation on Quaternions.Can you tell me please what program you used to do your demo?
    I am trying to understand how quaternions function. The program you presented evidently has functions which compute the steps required. Access to your source code for your example would be much appreciated. I am not a programmer but am very much interested in comparing the Euler approach with the Quaternion approach when rotating objects. This is an excellent program to do this comparison ! ! The code would help me understand the math involved. THANK YOU !!!!

  • @shrippie-4214
    @shrippie-4214 8 месяцев назад +1

    Nice
    will use them when I can

  • @NewSchattenRayquaza
    @NewSchattenRayquaza Год назад

    You have saved me hours of work thank you so much!

  • @nyeeesss2424
    @nyeeesss2424 Год назад +1

    That was really useful!

  • @prozacgodgamedev
    @prozacgodgamedev 10 месяцев назад

    Quaternions embody the phrase "Sit on it and spin!" - that's how I've always described them! haha

  • @prazza-vas-normandy
    @prazza-vas-normandy 4 месяца назад

    You are the best!!

  • @fistnine1061
    @fistnine1061 9 месяцев назад

    Good useful. Thank you! 👍

  • @trainzmarcel2074
    @trainzmarcel2074 8 месяцев назад

    this video is beautiful

  • @lalalala99661
    @lalalala99661 8 месяцев назад

    Thank you i guess now i understood very well explained

  • @Lucas-gg9yb
    @Lucas-gg9yb 3 месяца назад

    Great vídeo! One thing that is not clear to me in the your code: How are you obtaining this ijk value? Are you using local or global basis?

    • @SDGGames
      @SDGGames  3 месяца назад +1

      The sliders are just a vector3 and are pre-normalized. Once I have my numbers I want, I normalize this (make it length of 1), and build a new quaternion in global space using Quaternion(ijk, w). I then apply it to the box when I'm ready to rotate. I, J, and K are aligned with the X, Z, and Y axis in world space.

  • @a.j.outlaster1222
    @a.j.outlaster1222 6 месяцев назад

    I didn't even know what Gimbal Lock was before, Now I have a base understanding of quarternions.
    But I have a question, Wouldn't Euler XYZ be equivalent to Global ZYX?

    • @SDGGames
      @SDGGames  6 месяцев назад

      I'm not 100% sure what you mean by that. If you're talking about the Cartesian coordinate system, then yes, Godot uses Y as up instead of Z as up. Afaik, Godot is consistent internally, but other programs or equations might swap the axis.

  • @muuubiee
    @muuubiee 8 месяцев назад

    There were no planes when the mathmagician discovered quaternion, since that was something in the 1800's.

  • @ИванНекто-е2ч
    @ИванНекто-е2ч 2 месяца назад

    what if I have array of Vector3 points - whith I want rotate around... center of mass?

  • @trickster721
    @trickster721 9 месяцев назад +3

    This is a good idea and structure for a video, but you're speeding up around the key points instead of slowing down. You should focus a little more on the specific information that you're trying to communicate, maybe with stricter editing. When you fiddle around and improvise with the demonstrations, it makes it difficult to follow the point you're trying to illustrate. If I had no concept of Gimbal Lock, I don't think that section of the video would clarify it for me, and that's supposed to be the main conflict of the story.

    • @SDGGames
      @SDGGames  9 месяцев назад +2

      Thanks for the feedback! This one was a bit of an experiment, but I'll keep your advice in mind in case I do another video like this

  • @obsidianflight8065
    @obsidianflight8065 25 дней назад

    I don't understand how someone may lock the rotation using this method, if possible.
    Assuming you start using quaternions for a players camera for some reason... If you want to lock it to 30 degrees from the top and bottom so the player doesn't start flipping when going to far. I assume euler would fit this purpose better?

    • @SDGGames
      @SDGGames  24 дня назад

      Yeah, I'd probably use Euler. You can actually change the ordering, so if you are doing a camera, you can set it to rotate Y, then X, then Z. In the camera code, you can rotate Y and rotate X within limits, and Z is never needed. If your camera needs roll for some reason, then you might want to use quats instead.

    • @obsidianflight8065
      @obsidianflight8065 24 дня назад

      @@SDGGames True. If you *are* using roll it's also probably safe to say you don't need to limit the camera or can at least devise a system for it since roll is complicated

  • @DevMarco-
    @DevMarco- 8 месяцев назад

    Where i job we've got quinoa buns. You wouldn't believe how hard it is for some people to pronounce quinoa. From Kinoya, to Kichinoa or my all time favorite Kinocchio I've heard so many funny names.

    • @SDGGames
      @SDGGames  8 месяцев назад

      So, how did I do? I used to say quan-tern-eeon, until I realized there was no "N' in the middle...

  • @4.0.4
    @4.0.4 Год назад +1

    So... The point of quaternions is that they make it easy to rotate around a vector, right?

    • @SDGGames
      @SDGGames  Год назад

      Yeah, at least that's the primary use in game engines specifically. Other fields might use them exclusively for expressing any rotation. There are some other ways of dealing with rotations in Godot that I'll cover in my next video.

  • @l.halawani
    @l.halawani 8 месяцев назад +1

    Mathemagician

  • @Myth_Maker_Forreal
    @Myth_Maker_Forreal 8 месяцев назад

    can someone explain how to apply this to a camera?

  • @JoLo-vx1nb
    @JoLo-vx1nb 11 месяцев назад +1

    SORRY !! I did not realize that Godot was a programming language and the source code was available. I have to learn Godot. I do not know how to execute the Quaternion program yet. If you could give me a quick procedure on how this is accomplished I would appreciate it. THANK YOU !!!

    • @SDGGames
      @SDGGames  11 месяцев назад +1

      Godot is a game engine, you can download it for free and run the scene in it. If you download the source code from the GitLab link in the description, you can play around with the quaternion demo scene. There is a lot of stuff that Godot does automatically, so I'm not sure how useful the code will be as an example for other languages.
      I did try uploading the project to Itch, but web support isn't quite there yet for Godot. I'll keep an eye on it and try to get the demo up when I can.

    • @JoLo-vx1nb
      @JoLo-vx1nb 11 месяцев назад

      THANK YOU !! I was able to run the source code.@@SDGGames

  • @darklord8793
    @darklord8793 7 месяцев назад

    thanks man shit helped a lot

  • @AlanDarkworld
    @AlanDarkworld 4 месяца назад

    Thank you for the very nice and visual explanation. Even though quaternions are obviously superior in functionality, godot makes it a little too hard to use them. You mentioned that multiplying quaternions is the same as adding eulers. How are we supposed to know that? Why isn't there a "combine_with(....)" function on the quaternion class that properly deals with the math and exposes it in a language a non-mathematician can deal with? Not your fault of course :)

    • @SDGGames
      @SDGGames  4 месяца назад

      It's a hard balance to strike. If you re-invent the wheel, then the math people get upset because the function doesn't match reality. But, if you don't study the math, the game engine functions don't make much sense. I'm not sure what the ideal solution would be...

  • @kordanot
    @kordanot 8 месяцев назад

    Does the look_at() function use a quaternion?

    • @SDGGames
      @SDGGames  8 месяцев назад

      I'm not sure what it uses under the hood, but that function sets the rotation directly on the node. You can see the final rotation expressed as a quaternion, but I think the actual data is stored as a Basis.

  • @randomchannel-px6ho
    @randomchannel-px6ho 3 месяца назад +1

    I have serious questions about an education system that seems to go out of its way to hide this from most studentd becaude "its too complex"

    • @SDGGames
      @SDGGames  3 месяца назад

      It's definitely an issue with the system, but I wonder how many teachers actually understand these concepts themselves. If you get a degree in teaching, then you will never have the practical knowledge that comes from using math in a career. If you get a degree as an engineer or programmer, then you can make at least 3X a teacher's salary by not teaching.
      I feel like schools should welcome retired professionals to help teach the advanced concepts. Most of my college professors had a lot of experience in the workplace, and it showed. They were 10X easier to understand than the math professor because they were able to go beyond the theory and root the concepts in real projects they worked on.
      All that to say, the system is broken, but I don't think it's malicious. Just underfunded and overregulated

  • @makebreakrepeat
    @makebreakrepeat 11 месяцев назад

    Ro ro rotate your owl 🎵

  • @nicolaslanzoni9385
    @nicolaslanzoni9385 8 месяцев назад

    Ghin Baal L'qeh does sound ominous

  • @DevMarco-
    @DevMarco- 8 месяцев назад

    One big hurdle in understanding the slightest bit about quaternions is the naming of the components of a quaternion. Naming three of the four components x y and z implies concepts that are nothing like anything you know so far

  • @LeoPartIsntCool
    @LeoPartIsntCool 6 месяцев назад

    but why normalze the 4d vektor? wouldn't it be much easyer to use with our 3d brains if we just keep it as a vektor and an angle instead of representing it as a 4d vektor?

    • @SDGGames
      @SDGGames  6 месяцев назад

      It's not really designed for mere mortals to understand. I think I linked the 3Blue1Brown video on the topic. We use it for math reasons, not for convenience. Euler angles are more convenient, until gimbal lock kicks in

  • @l.halawani
    @l.halawani 8 месяцев назад +1

    You must be doing something very wrong.
    You're videos are very right, top of the line. Really great content.
    But you must be doing something wrong to have only 5k views on a video like this, when the video itself is so good.

  • @sheepcommander_
    @sheepcommander_ Год назад

    1:20 W

    • @SDGGames
      @SDGGames  Год назад

      It happens to the best of us... ¯\_ (ツ)_/¯

  • @boblako
    @boblako 11 месяцев назад

    Like and Subscribe! Great work 👍

  • @VoidX3.
    @VoidX3. 2 месяца назад

    the explanation of the concept of quaternions is very helpful but your code example in godot is very confusing as you don't explain much of the godot specific syntax, as well as having several variables that aren't explained

    • @SDGGames
      @SDGGames  Месяц назад

      Yeah, I probably should have broken down the code a bit more. Thanks for the feedback!

  • @RandomPickles
    @RandomPickles 8 месяцев назад +1

    I refuse to call Euler, OIL-er

    • @SDGGames
      @SDGGames  8 месяцев назад

      Yeah, I forgot to check. YOU'LL-er sounds like a Christmas drink to me, but it might be more correct

    • @RandomPickles
      @RandomPickles 8 месяцев назад

      @@SDGGames I think the way you prounounced it is the correct way. I just still refuse lol

  • @GeneralChrisGaming
    @GeneralChrisGaming 3 месяца назад

    So I do I apply this to godot trash animation playernso it shuts up and leaves me alone