Let's remove Quaternions from every 3D Engine: Intro to Rotors from Geometric Algebra

Поделиться
HTML-код
  • Опубликовано: 10 июн 2024
  • Interactive Article: marctenbosch.com/quaternions/
    [this video is the updated version of • Let's remove Quaternio... (fixed typos and different introduction)]
    To represent 3D rotations graphics programmers use Quaternions. However, Quaternions are taught at face value. We just accept their odd multiplication tables and other arcane definitions and use them as black boxes that rotate vectors in the ways we want. Why does i^2=j^2=k^2=−1 and ij=k? Why do we take a vector and upgrade it to an "imaginary" vector in order to transform it, like q(xi+yj+zk)q∗? Who cares as long as it rotates vectors the right way, right?
    Personally, I have always found it important to actually understand the things I am using. I remember learning about Cross Products and Quaternions and being confused about why they worked this way, but nobody talked about it. Later on I learned about Geometric Algebra and suddenly I could see that the questions I had were legitimate, and everything became so much clearer.
    In Geometric Algebra there is a way to represent rotations called a Rotor that generalizes Quaternions (in 3D) and Complex Numbers (in 2D) and even works in any number of dimensions.
    3D Rotors are in a sense the true form of quaternions, or in other words Quaternions are an obfuscated version of Rotors. They are equivalent in that they have the same number of components, their API is the same, they are as efficient, they are good for interpolation and avoiding gimbal lock, etc... in fact, they are isomorphic, so it is possible to do some math to turn a rotor into a quaternion, but doing so makes them less general and less intuitive (and loses extra capabilites).
    But instead of defining Quaternions out of nowhere and trying to explain how they work retroactively, it is possible to explain Rotors almost entirely from scratch. This obviously takes more time, but I find it is very much worth it because it makes them much easier to understand!
    For example, Quaternions are introduced as this mysterious four-dimensional object, but why introduce a fourth dimension of space to visualize a 3D concept? By contrast 3D Rotors do not require the use of a fourth dimension of space in order to be visualized.
    Trying to visualize quaternions as operating in 4D just to explain 3D rotations is a bit like trying to understand planetary motion from an earth-centric perspective i.e. overly complex because you are looking at it from the wrong viewpoint.
    It would be great if we could start phasing out the use and teaching of Quaternions and replace them with Rotors. The change is simple and the code remains almost the same, but the understanding grows a lot.
    As a side note, Geometric Algebra contains more than just Rotors, and is a very useful tool to have in one's toolbox. This article also serves as an introduction to it.
    ⦿ Support me on Patreon: / marctenbosch
    ⦿ Wishlist Miegakure on Steam: store.steampowered.com/app/35...
    ⦿ Buy 4D Toys on iOS: 4dtoys.com/ios
    ⦿ Buy 4D Toys on Steam: 4dtoys.com/steam
    ⦿ Mailing list: marctenbosch.com/mailing-lists
    ⦿ Blog: marctenbosch.com/news
    ⦿ Twitter: / miegakuregame
    0:00 Introduction
    2:30 1.1 - Rotations happen in 2D planes
    3:09 1.2 - Explicit Sense of Rotation
    3:36 2.1 - The Outer Product
    4:26 2.2 - Basis for Bivectors
    4:41 2.3 - 2D Bivectors
    6:17 2.4 - 2D Bivectors from non-unit vectors
    6:54 2.5 - 3D Bivectors
    8:15 2.6 - Semantics of Vectors and Bivectors
    9:01 2.7 - Trivectors
    9:42 3.1 - Multiplying Vectors together
    11:48 3.2 - Multiplication Table
    12:15 3.3 - The Reflection Formula (Traditional Version)
    12:55 3.4 - The Reflection Formula (Geometric Product Version)
    13:32 3.5 - Two Reflections is a Rotation: 2D case
    14:26 3.6 - Two Reflections is a Rotation: 3D case
    15:03 3.7 - Rotors
    15:35 3.8 - 3D Rotors vs Quaternions

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

  • @sirnukesalot24
    @sirnukesalot24 2 года назад +115

    Looks like the rotor isn't just a more generalized form that captures the quaternion, it captures the spinor as well. It might be worth pointing that out since spinors have been popping up in the public discussion within the last year or so.

  • @Toxo
    @Toxo 2 года назад +425

    If you really want to make an argument for replacing quaternions, I think you should establish that the new way is computationally equally or less expensive than quaternions. Using black boxes are a non-issue in software engineering, provided they do what you intended every time and aren't inefficient. Anyway, your video is really well made and I am grateful you made it!

    • @porky1118
      @porky1118 2 года назад +19

      They are isomorphic. The implementation would basically be the same.

    • @Ruktiet
      @Ruktiet 2 года назад +61

      @@porky1118 that's not what isomorphism implies. You could have an isomorphic structure that has representations and operations on those representations involving lots of computations compared to another one.

    • @porky1118
      @porky1118 2 года назад +7

      @@Ruktiet I would expect some data type to already use the most efficient algorithm possible. So if some isomorphic data structure to quaternions existed, which is more efficient, it would probably already have been used internally.
      Isomorphic would just mean, they have the same API, maybe with different names.

    • @z-beeblebrox
      @z-beeblebrox 2 года назад +63

      @@porky1118 "I would expect some data type to already use the most efficient algorithm possible."
      That is an INCREDIBLY optimistic assumption

    • @levknoblock88
      @levknoblock88 2 года назад +42

      @@Ruktiet Not only an optimistic assumption, but also an unrealistic one. Libraries for the same things constantly disagree on which data structures to use, even for something as common and 'simple' as matrix multiplication. On top of that, there are a lot of problems in CS where we just don't know what the most efficient approach is. And even then, the "best approach" changes depending on what computer you run the code on, so it's even more messy than that.

  • @ryanrising2237
    @ryanrising2237 4 года назад +767

    Why do I feel like I’m being sold on some kind of mathematical cult?

    • @kungfooman
      @kungfooman 3 года назад +20

      Because it looks fancy in ganja.js :^)

    • @nissimhadar
      @nissimhadar 3 года назад +8

      Do you think he is wrong?

    • @yabgu79
      @yabgu79 3 года назад +28

      I feel like it is intentionally obfuscated too. Geometric (Clifford) algebra is really so much better and easier to understand it cannot be a coincidence it is this hidden while videos like these exist: ruclips.net/video/d4EgbgTm0Bg/видео.html and they always use sentences as such: "See this figure is called linelander (I see myself there), his mind is so simple he cannot understand 4d concepts bla bla bla......". Isn't it too common these words used to be a coincidence? "You cannot understand because you are like line 2d lander trying to understand 3d while we demigods can grasp 4d space and all the magic...". Well... How about now; After watching this video I completely understand what 3d rotation is, so who was accusing me of being a simpleton...

    • @marctenbosch
      @marctenbosch  3 года назад +145

      I think the real cult is the quaternion guys 😂 since the real cult is always the other guys 😂. Seriously though, my sense is that it started with Hamilton and how he really wanted quaternions to contain 3D vectors (when in fact they contain bivectors) and trying to convince everyone of that, that we still feel the ripples today. If you're interested, look up the articles on the history at the end of the article: marctenbosch.com/quaternions/#history

    • @maxwellsequation4887
      @maxwellsequation4887 2 года назад +12

      @@marctenbosch Hmmmm it feels there is going to be crusades soon.....

  • @lukostello
    @lukostello 4 года назад +231

    I feel like there is an untold story of how you tried to code rotations in 4d for miagakure and discovered 4d rotors rather than a 5d solution. Then were like "well jeez if we dont need a 5th dimension for 4d rotations then why would we need a 4th dimension for 3d rotations?"

    • @marctenbosch
      @marctenbosch  4 года назад +171

      Yeah, except it is 8D, not 5D, ahah: marctenbosch.com/news/2011/05/4d-rotations-and-the-4d-equivalent-of-quaternions/

    • @petrowi
      @petrowi 3 года назад +22

      @@marctenbosch I'd be very curious to see a similar video for octonions. Loved this presentation

    • @williamchamberlain2263
      @williamchamberlain2263 3 года назад +18

      @@petrowi too right - octonions get far too much play in game engines.

    • @petrowi
      @petrowi 3 года назад +4

      @@williamchamberlain2263 my curiosity on the subject is not related to game engines

    • @mudkip_btw
      @mudkip_btw 2 года назад +43

      @@frankdimeglio8216 very elaborate shitpost

  • @schwajj
    @schwajj 4 года назад +229

    Thanks for a great explanation. I have a constructive criticism... I find it jarring when one equation cross-fades into an equivalent equation. I would prefer to have a new equation fade in below, so I can verify equivalence myself. This would make it easy to pause the video to compare the two equations. Instead, I have to rewind the video to see the previous equation. Going back and forth between the two equations is tedious. Thanks again!

    • @schwajj
      @schwajj 4 года назад +36

      An example of what I have problems with is 6:45, and what works for me is 13:05

    • @marctenbosch
      @marctenbosch  4 года назад +74

      Thank you for your suggestion.

    • @LeonardPauli
      @LeonardPauli 2 года назад +11

      @@marctenbosch I believe animations can help a lot, as long as they are connected to what's happening mathematically. I usually really enjoy the in-place animations, but yeah, in the 6:45 example, it was a bit jarring; for just elimination, fade is great, though when a term is moved, a movement animation may suitable (or just fall back on a new line).

    • @badradish2116
      @badradish2116 2 года назад +2

      colorizing the differences might help too

  • @mudkip_btw
    @mudkip_btw 2 года назад +34

    I have known geometric algebra was supposed to be more intuitive for a while. Recently I've used quaternions for the first time and I was really enthusiastic about how numerically efficient and stable they were, but I don't fully understand them. I think the next time I do a project involving 3d rotations, I will use the geometric algebra formalism. Thanks!

  • @DarkCloud7
    @DarkCloud7 Год назад +8

    It took a bit to digest, but after reviewing the article a few times I felt a sense of enlightenment. The stuff that seemed so out of the blue before (like the cross product) now fall into place so naturally. Thank you very much for this intro to geometric algebra.

  • @Alexander_Sannikov
    @Alexander_Sannikov 2 года назад +21

    For me the similarities between hypercomplex basis and a bivector basis were always obvious because I always thought of ijk basis as a bivector basis to start with. But I never realised that reflection about a and then reflection about b is the same is rotating by twice the angle between a and b. This actually was very insightful.

    • @writerightmathnation9481
      @writerightmathnation9481 2 года назад +2

      There are lots of useful resources if you really want to learn such stuff: Hestenes' Space-Time Algebra book, Hoffman & Kunze's Linear Algebra book, and Anadijiban Das' Tensor Analysis book. In this sense, a bivector is nothing but an element of a tensor product of a vector space with itself, and a bivector basis should naturally be a member of the canonical basis for such a tensor product, constructed using the tensor products of pairs of members of a given basis for the original vector space.

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

    Brilliant! I have wondered about cross products for decades, and even after working through the derivations algebraically they never really clicked. This video was a jolt of enlightenment. Thank you.

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

    Isn't it ironic that this guy is teaching us things that should prevent us from thinking in 4 dimensions?

  • @eeromutka186
    @eeromutka186 3 года назад +84

    Fantastic read/video! One thing that bugs me though if the fact that you're explaining everything in terms of XY, YZ and XZ planes, but things would get more consistent if you used YZ, ZX and XY planes instead. There are a couple of things that this fixes, let me explain.
    Firstly, if you take the cross product of the basis vectors of the XY plane, you'll get Z=1. For YZ plane, you'll get X=1. But with XZ, you'll get Y=-1. Seems very wrong right? Using ZX not only fixes this, but also it's quite logical that Y comes after X, Z comes after Y and, after wrapping around, X comes after Z.
    At 7:43, you explain how the outer product is almost like the cross product, but the value for Y is negative. But by using ZX, this also gets fixed and the values are identical! Also, if you fix the order so that it's [YZ, ZX, XY] and not [XY, YZ, XZ], it'd match up with the rows of the matrix you'd get from a cross product.

    • @marctenbosch
      @marctenbosch  3 года назад +37

      Yeah I think both have advantages. I have an aside in the article (marctenbosch.com/quaternions/) that says:
      "I chose a lexicographic order for the basis because it is easy to remember, but choosing z∧x instead of x∧z would make the signs the same. It would also makes the bivector basis directions consistent. This is the right hand rule, except the understandable non-arbitrary version :)"
      It does become more difficult to define in 4D and higher: should it be YW or WY ? So I think lexicographic order is helpful then.

    • @OMGclueless
      @OMGclueless 2 года назад +5

      ​@@marctenbosch If you choose an ordering and then take the (circular) pairs of unit vectors as your bivector basis, it should work out in all dimensions, no? Sure, it doesn't tell you whether it's `yw` or `wy`, but neither of those bivectors are basis bivectors in the standard basis. And if you were to project the 4D space into a 3D space the choice of `yw` or `wy` would be dictated pretty naturally by your choice of projection following the same logic (for example, in `wxy` space it's `yw` and in `wyz` space it's `wy`).

    • @theodorostsilikis4025
      @theodorostsilikis4025 2 года назад +10

      Staying consistant with the permutations becomes much more relevant in higher dimensions .In 3vectors xyz,yzx,zxy have the same sign,imagine xyz,yzx,-xzy...

    • @ZedaZ80
      @ZedaZ80 2 года назад +1

      Oh, that's pretty helpful :0

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

      Of of the things I love about geometric algebra is that it doesn't matter whether you use xz or zx, because the two will always be negatives of each other. With quaternions and cross products, there is only 1 choice of basis and it's rather arbitrary. With geometric algebra, you have two options for each basis bivector and can store them however you like as long as you understand xz = -zx. Some sources use wx, wy, and wz, along with a cyclic permutation of the other 3, while others use xw, yw, and zw.

  • @AttaKru
    @AttaKru Год назад +3

    1:43 if you think about matricies, and vectors. If you want 3D transformation (nost just rotation but translation and scaling) with them, you need one extra dimension, hence a 4x4 matricies and x,y,z,w homogenous vectors are needed in to order express such.

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

    I have watched many tutorials, and this one by far is the best. Thanks.

  • @r.pizzamonkey7379
    @r.pizzamonkey7379 2 года назад +46

    I feel like the name is slightly clickbait. What it seems like you're actually arguing here is a different way to teach quaternions. I don't think using this approach would actually change anything about how a 3D engine is implemented under the hood.
    At best it would be some different identifiers and documentation, but once you compile and optimize everything you're left with the same end product.

    • @primarysecondaryxd
      @primarysecondaryxd 2 года назад +3

      Check out watch?v=tX4H_ctggYo if you're interested.
      I think it works out to a very small memory advantage over matrices in the 2d/3d case if the whole thing was implemented under the hood (otherwise I think it all works within one matrix per object), with much more generality between 2d and 3d as well as simplifying the implementation (less exceptions to deal with, everything is one type, 2d functions work for 3d and vice versa) from the programmer's side.
      That said it's hard to use when game engines don't have a native implementation and you have to translate between everything yourself.

    • @r.pizzamonkey7379
      @r.pizzamonkey7379 2 года назад +9

      @@primarysecondaryxd what I mean is if j really is just yz, and you don't want to implement an entire general CAS solver when all you need is a few specific cases, you're going to end up with the same ijk lookup table just written with the bivectors, as seen in section 3.2. I mean, it's the same as your standard quaternion table except they omit the identity operation (1x), but it's not really necessary there either.

    • @MathAndComputers
      @MathAndComputers 2 года назад

      I noticed this, too, and also that quaternions usually aren't used for rotating vectors, since for more than a handful of vectors, it's more efficient to convert to a rotation matrix first and use that. Quaternions are usually used for composing transforms or blending transforms, since they're more efficient than matrices for those, at which point, I'd be curious whether dropping the real component like this might lead to inefficiency. 🤔

    • @LukeVilent
      @LukeVilent 2 года назад

      @@MathAndComputers You're not dropping the real component here. Since rotors and quaternions are the same, identical thing, captured by the math term "isomorphic", a product of two general rotors will almost certainly produce a rotor with a real part.
      UPD. Maybe, you were meaning replacing unit quaternions with their Lie algebra counterparts. I've tried that - not the best idea.

    • @MathAndComputers
      @MathAndComputers 2 года назад

      @@LukeVilent Isomorphic doesn't mean that they're the same, identical thing; it means that they're mathematically interchangeable. As described in the video, rotors are 3 components; quaternions are 4 components, i.e. the 3 components of rotors, plus an additional component that can be computed from the other 3 (ignoring the sign) if only unit quaternions are relevant. The sign is sometimes needed, which technically makes them not isomorphic, but even if we ignore that, and even if isomorphic did mean that they're exactly the same, then "rotor" would be a redundant term for "quaternion", and removing quaternions from all 3D engines would mean removing rotors from all 3D engines, and the title of the video is still contradicted by the video, which is pretty much the point I was making in the first place.

  • @Alexander_Sannikov
    @Alexander_Sannikov 2 года назад +11

    I think the greatest confusion in understanding quaternions comes from the fact that in 3d the dimentionality of an axis of rotation is the same as dimentionality of the space itself. This is not the case for any(?) other dimensionality. Because of this, we think of rotation axes as if they were part of the same space when they are really not, which's particularly obvious in non-orthogonal bases.

    • @writerightmathnation9481
      @writerightmathnation9481 2 года назад +1

      What do you mean by "dimensionality of an axis of rotation", please? Let's stick to the three dimensional case for now. In my view, the dimension of an axis of rotation in three-space is 1 because it is a line ( a translate of a one dimensional real subspace of thre space), but the dimension of three-space is not 1. The term "dimensionality" is strange to me and undefined in this context.

    • @Alexander_Sannikov
      @Alexander_Sannikov 2 года назад +3

      @@writerightmathnation9481 by dimensionality i mean "units of measure". dimensionality of axis of rotation is not units of vector space, it's units of bivector space. So it's not [meters]^3, but rather [meters*meters]^3

    • @JivanPal
      @JivanPal 2 года назад

      ​@@Alexander_Sannikov, rotations are dimensionless, since they are angles. The result of a cross product merely encodes a plane and a scalar corresponding to something related to that plane (e.g. a rotation, angular velocity, torque, etc. in that plane). A vector is simply a nice way to encode both of these things together.

    • @Alexander_Sannikov
      @Alexander_Sannikov 2 года назад +1

      @@JivanPal rotations are only dimensionless in a dimensionless space. But you can easily consider a space that has its own dimensionality. In fact, typically spaces in physics are measured in physical units of length (meters, etc), but you can easily imagine a hypothetical abstract space where each basis vector has its own unit of measure associated with it. Since decomposition by these unit vectors is unique, each vector of this space will have a unique measure composition as well. And then you'll notice that in order to define a rotation axis in this hypothetical space, you CAN'T use a vector of the same space, you need to use a vector of so-called dual space, and dual space is a space of bivectors.
      Another hint to why rotation axis can not have the same dimensionality in general as the space itself: only in 3d axis of rotation has the same number of dimensions as a vector that it rotates. For example, in 2d space your axis of rotation is 1d, and in 4d space your axis of rotation has 6 components (which is the dimentionality of dual space associated with it).

    • @porky1118
      @porky1118 2 года назад +1

      @@writerightmathnation9481 Dimension is the correct term: en.wikipedia.org/wiki/Vector_space#Basis_and_dimension

  • @JohnTan
    @JohnTan 2 года назад +33

    8:17 Just to clarify, the vector given by cross product is not a "confusion". It is a result of Hodge duality in the exterior algebra. Aka the hodge dual of x is exactly y^z and so on.

    • @user-hh5bx8xe5o
      @user-hh5bx8xe5o 2 года назад +6

      That's true but the cross product is only relevant in 3D as the dual of a bivector is of dimension n-2 so only mapping vectors to vectors when n is 3.

  • @PS3PCDJ
    @PS3PCDJ 2 года назад +4

    Cant wait for Randy to find this and then watch him go and refactor most of his code to get rid of the Quaternions he just learned about and implemented into his game

    • @LukeVilent
      @LukeVilent 2 года назад +2

      And find out that he replaced quaternions with... quaternions.

  • @ChrisDjangoConcerts
    @ChrisDjangoConcerts 2 года назад +1

    Very good video ! I learned new things while already familiar to the subject Good job Marc !

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

    That was a mind blowing presentation, done in incredibly thoughtful and complete way, it does make it click. Would like to see more from you if there will be a chance.

  • @rogierbrussee3460
    @rogierbrussee3460 2 года назад +5

    So Clifford algebras (which is what geometric algebras are except without the cult of Hestenes) are really useful. For example they are fundamental for the notion of spinor. In particular |H = Cl(|R^2, Q) where Q is negative definite inner product.
    But there is nothing strange about the Quaternions. Them being 4 dimensional comes from the space of all rotations SO(3) being 3 dimensional and its universal cover Sp(1) being a 3-sphere. Of course a 3-sphere naturally sits in a 4 dimensional space: exactly the three sphere of unit quaternions.
    It works as follows. The space of imaginary quaternions Im(|H) = {v\in |H | v = x I + yJ + z K} is clearly a 3D space with
    v\bar v = x^2 + y^2 + z^2
    the standard inner product. let
    Sp(1) = { q \in |H | ||q|| = q \bar q = 1}
    Then Sp(1) is obviously a 3-sphere. Note that the Lie algebra sp(1) consists naturally of the quaternions h such that
    (1 + \epsilon h) (1 + \epsilon \bar h) = 1 + \epsilon ( h + \bar h) + O(\epsilon^2) = 1 + O(\epsilon^2)
    i.e. h \in Im(|H).
    Moreover Sp(1) acts on Im(|H) by
    v --> q v \bar q
    This is an orthogonal transformation of Im (|H) since
    \bar (q v\bar q) = q \bar v \bar q = - q v \bar q
    and
    q v \bar q \bar(q v \bar q) = q v (\bar q) q \bar v \bar q = q v \bar v \bar q = ||v||^2 q \bar q = ||v||^2
    In fact it defines a rotation because Sp(1) is connected so the determinant of v --> q v \bar q which can only take on the values ±1 must be constant 1. This explains how quaternions give rise to rotations, and clearly q and -q give rise to the same rotation.
    (1 + \epsilon I), (1 + \epsilon J) and (1 + \epsilon K) as a matrix on Im(|H) and keep the first order terms e.g.
    (1 + \epsilon I) I (1 - \epsilon I) = 1 +\epsilon [I, I] + O(\epsion^2) = 1 + O(\epsilon^2)
    (1 + \epsilon I) J (1 - \epsilon I) = 1 + \epsilon [I, J] + O(\epsilon^2) = 1 + 2\epsilon K + O(\epsilon^2)
    (1 + \epsilon I) K (1 - \epsilon I) = 1 + \epsilon[ I, K] + O(\epsilon^2) = 1 - 2\epsilon J + O(\epsilon^2)
    lie algebra element I corresponds to the matrix
    1 0 0
    0 0 2
    0 -2 0
    Proceeding similarly for J and K we see that sp(1) --> SO(3) is an isomorphism.
    The map Sp(1) --> SO(3) is then open, and since Sp(1) is compact it is also closed, so the image of Sp(1) is a closed and open subgroup of SO(3) which must be everything.

  • @rotgertesla
    @rotgertesla 2 года назад +1

    I really like the interactive article you provided with your video! Very good idea. Suggestion : it would be nice if we could pause the animations in the interactive doc

  • @AndrewJonkers
    @AndrewJonkers 2 года назад +1

    Very nice. I had the same questions about quaternions that you did regarding dimensionality.

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

    this is awesome. i am a huge fan of going back to basic principals when the rules of thumb youve been given dont hold up. i really appreciate this approach

  • @ObsessiveClarity
    @ObsessiveClarity 2 года назад

    7:13 I've been looking for this visualization for some time. Thank you.

  • @bluceree6897
    @bluceree6897 2 года назад +13

    Man, I wish i was smart enough to understand any of it and how to properly utilize it in my code :(

    • @galvanizeddreamer2051
      @galvanizeddreamer2051 2 года назад +9

      Bookmark it, and come back to it after taking an entire course on geometric algebra or something.
      Because you can bet your arse that's what I'll be doing.

  • @LAK132
    @LAK132 4 года назад +7

    Hi, thank you for this video! I'm looking through your code, and I'm having a hard time working out how you came up with this implementation. I see the trivector value in there, but I can't work out how that comes out of the bavab equation?

    • @marctenbosch
      @marctenbosch  4 года назад +7

      You have a rotor that is r=a*b, then you first multiply v by r, that gives a vector + trivector, then you multiply the result of that by reverse(r) and that kills off the trivector part.

  • @arnoldn2017
    @arnoldn2017 2 года назад +23

    Quarter ions are nicely wrapped Rodriguez rotations. The only point I see in favor of quaternions is that it is possible to multiply them with a ‘C-O’ quaternion to mathematically align an observation quaternion to a body quaternion for real time applications like on seagoing vessels

    • @platinummyrr
      @platinummyrr 2 года назад +2

      That's the primary advantage I found when trying to do a 3d rubics cube program. It was frustrating to have traditional naive rotations break in weird ways when you tried to drag parts of the cube. (If you rotated the cube 180* about an axis, then naive rotations would flip the wrong intuitive way because they were being applied wrong). Using quaternions I was able to easily translate the input into the desired motion.

  • @ChrisOffner
    @ChrisOffner 3 года назад +35

    Can you recommend any great resources (books, lecture playlists, etc.) on Geometric Algebra?

    • @elijahlape
      @elijahlape 3 года назад +14

      A nice introductory book is Volume 1 from this series: foundationsofgameenginedev.com/
      Playlist: ruclips.net/p/PLpzmRsG7u_gqaTo_vEseQ7U8KFvtiJY4K

    • @writerightmathnation9481
      @writerightmathnation9481 2 года назад +1

      Hestenes

    • @ChrisOffner
      @ChrisOffner 2 года назад +1

      @@writerightmathnation9481 Do you mean "Clifford algebra to geometric calculus: A unified language for mathematics and physics" by David Hestenes and Garret Sobczyk?

    • @plus-sign
      @plus-sign 2 года назад +3

      I'm reading "Geometric Algebra for Computer Science" (Dorst, 2007). Good if you're a programmer.

    • @ChrisOffner
      @ChrisOffner 2 года назад

      @@plus-sign Cheers, I'll check it out.

  • @IElial
    @IElial 2 года назад +1

    Nice video ! I feel like I am still unaware of more and more stuff the more I learn new one. I heard of quaternion reading of book about DirectX 9 back in the days, without totally understanding it beyond that it is better because it solve gimbal lock. And now I discover there was a whole algebraic side developped end of 19th Centurty as a better Quaternion solution !

  • @SteinCodes
    @SteinCodes 2 года назад +2

    Sorry for only watching it now, but incredible stuff, I feel dumb for just accepting quaternions in all my code as it is, till now. They would have made the like of high school me, trying to learn graphics programming so much easier, thanks a lot.
    I had taken multiple courses in Maths, wasted several hours working on geometric algebra but never did I think of using it. So thanks a lot. 😊
    I will try and port as much of my code to rotors as possible, and only leave a quaternion api as a secondary solution. :)

  • @renexmachina
    @renexmachina 2 года назад +11

    i didn't really understand anything despite a background in videogame graphics, but i feel like my efforts avoiding quaternions all these years have been justified.

    • @Sh-hg8kf
      @Sh-hg8kf 2 года назад

      As a beginner planning to learn 3d graphics, same XD. Hopefully I can understand this soon enough

    • @SteinCodes
      @SteinCodes 2 года назад +1

      Clear up your head rewatch it from the outer product part. It will flow quite well. I had started watching the video with too much bias because of the title so had a lot of issues in understanding on first attempt it's extremely simple.
      Basically your cross product gives you a perpendicular vector which adds complexity while you can avoid it by simply using a bivector instead which is an outer product.
      Outer product of same vectors is 0 is an base identity of it, and allows to build other identities required for implementation.
      3D bivectors are slightly confusing as they need understanding of plane projection to get their components but the essence is all the same. But here computer is doing the maths so it's not a concern.
      Otherwise bivectors are the same as cross product in equations just use basis planes instead.
      The best part though is the fact that they can scale infinitely(bi - tri - quad), it's part of multivector algebra. And truth be told I knew about it to some extent just never thought of using it. Search Wikipedia for Multivector and Clifford Algebra on internet.

    • @Sh-hg8kf
      @Sh-hg8kf 2 года назад +1

      @@SteinCodes What level of math background does one need to understand this video and the topic at hand in your opinion?

    • @SteinCodes
      @SteinCodes 2 года назад

      @@Sh-hg8kf Whatever level I am at, so around a little more than High School. Or a few years of experience writing/working game engine rendering source.
      For the purpose of brevity anyone who graduated with Maths as a subject in college.

    • @Sh-hg8kf
      @Sh-hg8kf 2 года назад

      @@SteinCodes How would one tackle this prior to finishing high school math? Linear algebra was barely taught here, with a brief explanation of matrices, steps of matrice multiplication given without intuition and determinants to give a perspective. Any stuff I should cover on top of these (I am a bit decent with the multiplication intuition now)? Since our syllabuses might be diff, idk how much stuff matches up.
      Also, wait, if a engine dev with years of experience can understand this, most normal starting-out game devs would find this hard and thus not have to implement stuff like this and quaternions?

  • @NikolajKuntner
    @NikolajKuntner 2 года назад +23

    I feel you start this out with a non-argument: "I wasn't taught why quaternions work, so here's an alternative..."

    • @LukeVilent
      @LukeVilent 2 года назад +13

      "Working out quaternions is hard, so let's replace this rusty crap with the algebraic completion of 2-wedge products over three generators, which are quaternions, but now lactose and gluten free."

    • @NikolajKuntner
      @NikolajKuntner 2 года назад

      @@LukeVilent lol

  • @jperez7893
    @jperez7893 2 года назад

    beautiful explanation!

  • @gnramires
    @gnramires 7 месяцев назад +1

    I think this would benefit from deriving rotors of an axis-angle rotation. (I think insight sometimes comes from connecting many viewpoints, not just a single one), I found that missing after describing rotors from reflections. But rotors do seem quite compelling, as well as GA as a whole! Thanks.

  • @infinummjb
    @infinummjb 2 года назад +4

    OMG, this is brilliant! So coherent and intuitive - love it!

  • @roger_isaksson
    @roger_isaksson 2 года назад +2

    Excellent. I didn’t know there was an alternative to quaternions. 👍

    • @ZedaZ80
      @ZedaZ80 2 года назад +1

      Yeah, same, this is pretty cool.

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

    Some rather interesting comments ! I'm not even going to pretend that I'm qualified to add anything useful here but, I will say that I'm grateful for those who took the time & effort to understand this stuff. & especially for those who actually came up with it in the 1st place, as well as anyone who attempts to teach it.

  • @dakotapearl0
    @dakotapearl0 2 года назад +2

    Really interesting! It's like quaternions are a simplification of this concept. What I'm trying to figure out is if the implementation of rotors in a 3D game engine can be as efficient as quaternions. How much information needs to be stored for each rotation and how many operations need to be done per rotation?

    • @nzuckman
      @nzuckman 2 года назад +7

      Quaternions are an even subalgebra of the Cl(3) geometric algebra - if you throw out the vectors and trivectors, you're left with scalars and bivectors whose algebra is exactly the same as the quaternions. They contain the same information, although a geometric algebra has *slightly* more overhead because it has the vectors and trivectors too - however, the intuitive understanding gained from this is well worth it.

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

    What helped me understand what was going on “under the hood” with quaternions, was learning that Hamilton was studying a great deal about systems of longitude and latitude. Rotate on one edge by latitude, then rotate by longitude, and you apply a scalar. Also gimbal lock is entirely avoidable, if you learn to rotate from stored positions of origin.

  • @QRebound
    @QRebound 4 года назад +41

    Great video, but early on you say that rotors and quaternions are isomorphic, and in the same breath say that quaternions have less capabilities than rotors. That would mean they aren't isomorphic, wouldn't it? If they truly are isomorphic, it may be more *awkward* to use quaternions for some things, but they'd still be capable of everything rotors are.

    • @marctenbosch
      @marctenbosch  4 года назад +41

      3D Rotors (the even subalgebra of 3D geometric algebra) are isomorphic to quaternions, but they can also operate on things that are not isomorphic to quaternions via the full geometric algebra.

    • @trueriver1950
      @trueriver1950 2 года назад +3

      @@marctenbosch
      So more exactly what you meant is that rotors contain a subset that is isomorphic to quarternions?
      That might make rotors a useful extension to quarternions even apart from being more intuitive.
      Do you have an example of a physical effect that can be modelled by a rotor operation but not with quarternions?

    • @elkinmontoya9640
      @elkinmontoya9640 2 года назад

      @@marctenbosch Is this isomorphism local, or global?

    • @polyhistorphilomath
      @polyhistorphilomath 2 года назад +1

      @@trueriver1950▽F= μ_0 c J. Maxwells equations with the laws as 0-, 1-, 2-, 3-vector components

    • @polyhistorphilomath
      @polyhistorphilomath 2 года назад +1

      It’s not really a proof of inapplicability. But the Clifford algebra representation is concise if nothing else.

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

    What makes quaternions special is that they’re one of the four composition algebras (the real numbers, the complex numbers, the quaternions and the octonions) and their automorphism group is exactly SO(3).

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

    I think this needs a follow up video: "Let's remove arrows from every 3d engine: an introduction to plane-based projective geometric algebra"

  • @moonmakesmagic
    @moonmakesmagic 3 года назад +1

    I'm still using quaternions because, well, existing APIs, but this was very well explained and helpful

  • @danielb270
    @danielb270 2 года назад +2

    The reason Quaternions are used is because they can be computed and represent as a 4x4 matrix - matrix addition and matrix multiplication is what GPUs specialize at.
    ALL 3D graphical 3d applications use a single 4x4 matrix to represent position, rotation and scale. And it is used to perform screen projection.
    One way or another to represent rotation inside the engine quaternions are the optimal solution as it costs a single matrix addition.
    If you want you can create whatever wrapper level you want, but at the end YOU MUST provide 4x4 matrix to the GPU for rotation (unless you develop a new hardware architecture, graphics API, and with a better performance)

    • @joeedh
      @joeedh 2 года назад

      GPUs are SIMD (single instruction multiple data) machines. They don't require 4x4 matrices per se. Some engines will work in quaternions for real-time skinning, only using the final camera matrix at the end..

    • @danielb270
      @danielb270 2 года назад

      @@joeedh they don’t require 4x4 matrices, but they have hardware specifically for those operations

    • @blinded6502
      @blinded6502 2 года назад

      Quaternions are rotors. They are literally rotors, but they are named wrong. And because people don't understand how do they work (in terms of GA behind it), they can't fully utilize them. And there's a ton of features that GA framework provides.

  • @doce7606
    @doce7606 2 года назад

    Perhaps an adjoint to re-imagining continuum mechanics after Koenman. Plus, a prompt to scrap baffling inverse and transpose vector operations to describe simple planes and volumes. But as a simpleton myself, can i just check the relation with (aa bb) diads? Also, can you show this in spherical coordinates...?

  • @lettuan1982
    @lettuan1982 2 года назад

    amazing work!

  • @Taronites
    @Taronites 2 года назад +8

    This totally beats any OBE meditation. By the 10th minute I find myself hovering at least 7 inches above my chair. ^^

  • @erickweil4580
    @erickweil4580 4 года назад +4

    Also, how is the geometric product generalized to 4D when you have Bivector x vector? from my calculations it produces a vector plus four trivector parts. Those trivector parts can be dropped out? my Geometric Algebra understanding only was able to make 3D Rotors work.

    • @erickweil4580
      @erickweil4580 4 года назад +1

      After doing some math, actually those trivector parts are used in the second multiplication of the rotation sandwitch. I'm not sure if its 100% correct but it worked so far. Thanks for this video and article.
      In a future article you could talk a little bit about Rotors is in 4D, is not that trivial.

    • @marctenbosch
      @marctenbosch  4 года назад +1

      The trivector part drops out when doing the full sandwich product, yes.

    • @erickweil4580
      @erickweil4580 4 года назад +1

      @@marctenbosch To solve it I ended up doing a program that expands the geometric algebra expressions following the rules and then getting only the final reduced formula(used python and the library sympy)
      So rotor multiplication and matrix conversion worked perfectly.
      But...
      I found some problems while interpolating 4D Rotors, as with some combinations of rotors the result is a rotation with scaling.
      I didn't found any resources about log or square roots of rotors ( also exp is very very slow ) as there is a way to interpolate that requires this calculation (multiplicative interpolation)

  • @samisiddiqi5411
    @samisiddiqi5411 3 года назад +3

    Curiously, what does the fourth dimension mean for motion in quaternions?

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

      ijk dimensions are for "heading" of the object and fourth dimension is for rotation around the ijk vector. Btw this is funny: en.m.wikipedia.org/wiki/Axis%E2%80%93angle_representation

  • @OriginalJetForMe
    @OriginalJetForMe 2 года назад

    This is really great. I’m tempted to implement this and see if I can make it use SIMD.

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

      I think others have done that already!

  • @JanPBtest
    @JanPBtest 2 года назад +5

    Mathematicians call it "Clifford algebra" and "Clifford multiplication". I don't know where the terms "geometric algebra" and "geometric product" came from originally. Likewise, the wedge product of vectors is a part of "Grassmann algebra". I agree all this should be taught early on, along the standard vector product (which can be very useful too, it works not only in 3D but as a product of (n-1) vectors in n-D.

    • @kvazau8444
      @kvazau8444 2 года назад +5

      the term "geometric algebra/product" came from clifford himself.

    • @JanPBtest
      @JanPBtest 2 года назад

      @@kvazau8444 I wonder why the name did not stick with mathematicians.

    • @MichaelPohoreski
      @MichaelPohoreski 2 года назад +2

      Jan I'm not sure where you are getting the lie that Mathematicians don't call it Geometric Algebra. Austrian Mathematician Emil Artin has a 1957 book called _Geometric Algebra._

    • @JanPBtest
      @JanPBtest 2 года назад

      @@MichaelPohoreski I never heard the term "geometric algebra" used in the areas connected to manifold geometry and topology. I'm sure it's used in _some_ areas of mathematics. But then I left academia 20 years ago so perhaps things have changed today.

    • @MichaelPohoreski
      @MichaelPohoreski 2 года назад

      ​@@JanPBtest The problem is a LOT of math teachers are horrible teachers teaching by rote, suck the passion out of kids, and are ignorant about modern topics such as bivectors, why the cross product only being defined in 3 and 7 dimensions is a problem, don't teach that the imaginary value i = sqrt(-1) is a 90° rotation, etc. This is mostly due to their teachers being uninformed and bad as well.
      You'll want to read Paul Lockhart's _A Mathematician's Lament_ that gives a depressing but accurate summary of the state of teaching mathematics.

  • @MarkKrebs
    @MarkKrebs Месяц назад +1

    I guess I'll pitch a monkey wrench at this. I *love* quaternions. When you have a rotation, thinking of the two-d case (where Bosch begins) the axle about which the rotation happens lies in the third dimension. In this way it's not too unnatural to imagine that 3-d rotations might need 4 elements to describe them. Quaternions anticipated the mathematics of vector calculus eg Maxwell's equations and aerodynamics and quantum mechanics etc etc. Don't be scared off too easily, quaternions are great.

  • @trueriver1950
    @trueriver1950 2 года назад +2

    The case for quarternions in mechanical motion is greatly enhanced by special relativity, because throughout SR time and space turn up squared but with opposite signs.
    One approach is to just write the formulae with three minus signs.
    Another is to always multiply times by ic (the square root of minus one times the speed of light).
    The most elegant solution is to bundle the "imaginaryness" into the spatial coordinates giving quarternions where the real component of time-distsnce (or of energy-momentum) is time (or energy) and the three imaginary components represent the three spatial components the spatial separations (momentum).
    This produces a delightfully simple version of the otherwise complicated expressions that relate how a moving and stationary observer respectively measure energy momentum, spatial separations, time differences.
    As seen from a moving observer, the transformed values are simply a rotation in a plane containing time and one spatial direction. The maths looks identical to any other rotation.
    If you never intend to incorporate relativity into your physics then I agree rotors make more intuitive sense than quarternions.
    But I have never seen the same represented using rotors.
    Until I do, I am not convinced it is possible, and therefore in my mind there remains a place for quarternions, even if that place is not in the coding of gaming engines and virtual reality.

    • @user-hh5bx8xe5o
      @user-hh5bx8xe5o 2 года назад +4

      Check en.m.wikipedia.org/wiki/Spacetime_algebra for a treatment of space time with geometric algebra

    • @SpaghettiToaster
      @SpaghettiToaster 2 года назад +4

      "Until I do, I am not convinced it is possible, and therefore in my mind there remains a place for quarternions, even if that place is not in the coding of gaming engines and virtual reality."
      They're isomorphic so clearly it must be possible.

    • @blinded6502
      @blinded6502 2 года назад +2

      Bruh. There's a literal branch of spacetime algebra in geometric algebra, that does exactly that.

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

      lorentz transformations can be expressed as a single rotor

  • @sumdumbmick
    @sumdumbmick 2 года назад +40

    as a general rule when the people around you are all dogmatically saying the same thing and nobody can explain why, it is more than legitimate to question it.

    • @michaeltsouris8190
      @michaeltsouris8190 2 года назад +11

      if you're surrounded by people who can't explain something that is well documented, you're asking the wrong people.

    • @ericy1817
      @ericy1817 2 года назад +1

      @thatonespathi Sometimes these things honestly just fall to convention. Both pi and tau have their merits, its just that people started using pi first so we stuck with it.

    • @danielb270
      @danielb270 2 года назад +1

      Any Computer Graphics Course (the coding kind) in University should explain it.
      Also, super-short answer: that is how GPU's work, so ANYTHING else would be slower.

    • @omp199
      @omp199 2 года назад

      @@ericy1817 I am unaware of any merits to using pi rather than tau, other than that all the works of reference already use pi.
      Also, there are all these people talking about quaternions here, but I can't see any mention of why they were a thing in the first place.
      The Wikipedia article sums up why quaternions are a thing: in 1877, Ferdinand Georg Frobenius proved that for a division algebra over the real numbers to be finite-dimensional and associative, it cannot be three-dimensional, and that there are only three such division algebras: the real numbers, the complex numbers and the quaternions, which have dimension 1, 2, and 4 respectively. That's what makes them special.

  • @petrowi
    @petrowi 3 года назад +7

    I'm very eager to see these 4D rotations and movement in Miagakure, is it coming out?

  • @budasfeet
    @budasfeet 4 года назад +1

    Sorry I’m leaving bunch of questions here because I don’t see commenting section in your article webpage on my phone.

  • @edomeindertsma6669
    @edomeindertsma6669 2 года назад +1

    11:42 that 'property bundle' reminds me of quaternions.

  • @nietschecrossout550
    @nietschecrossout550 2 года назад +1

    Are there any benchmarks on what can he computer faster? 4D 32bit floating point numbers smell of superscalar optimisation, do they not? To the best of my knowledge with a length 3 vector youll end up with 4 byte of wasted memory on your GPU per operation.

    • @JivanPal
      @JivanPal 2 года назад +2

      It sounds like you're advocating the use of 3D vectors rather than either quaternions _or_ rotors. If that's the case, you need to realise that the whole reason quaternions are used in computer physics in the first place, rather than 3D matrix algebra, is that matrix algebra suffers certain problems (such as gimbal lock when interpolating rotations) that the former overcomes.
      As for computational time/complexity, there is not much overhead. Multiplication is fast, and these days we have ICs expressly designed to do this kind of computation as fast as possible. That's what in your GPU. As for memory, consider that power-of-2 multiples of allocated memory are generally preferred because of chip/DIMM design. That is, if I have a 3D vector data structure comprising three 32-bit numbers, it is likely that when I instantiate multiple instances of it, they will be aligned on 64-bit or 128-bit boundaries rather than 32-bit boundaries anyway, so you don't actually save any memory from a practical standpoint.

  • @PhantomKING113
    @PhantomKING113 2 года назад +4

    I knew it! The multiplication table at 12:10 looked familiar, and that's for a simple reason: since rotors and quaternions are isomorphic, there's no way to run away from them.
    Basically, rotors use 2 leters for the same thing for which a quaternion uses 1; though idk how to emulate vectors with quaternions, I am not a mathematician...
    Let's say xy is like i, and yz like j, then xz is like k and we get the following multiplication tables:
    \ *1 xy yz xz*
    *1* 1 xy yz xz
    *xy* xy -1 xz yz
    *yz* yz xz -1 xy
    *xz* xz yz xy -1
    So it's just quaternions again.
    As for the other table:
    \ *1 x y z*
    *1* 1 x y z
    *x* x 1 xy xz
    *y* y xz 1 yz
    *x* z xz yz 1
    In quaternions, that probably also has some representation, but I am not a mathematician or anything like that so I'ma stop here before I get something wrong.
    Anyway, cool video!
    Also, the quaternion multiplication table doesn't come out of nowhere, there's logic to it...
    Edit:
    Btw, 3D rotors are also 4-dimensional, so don't get confused. If you represent the xy component on the z axis, the yz component on the x axis and the xz component on the y axis, you still need a fourth axis for the scalar part (if that was how it was called). So no, rotors aren't any simpler, they just favour a different angle from which to approach the same overall mathematical system.

    • @angeldude101
      @angeldude101 2 года назад +1

      The 4th component is the scalar-part, correct. It can also be called the 0-vector or grade-0 vector since it's a product of 0 basis vectors.
      From what I understand, quaternions were originally conceived as the quotient of two vectors, so your second table is probably not far off from how Hamilton defined them since the inverse of a vector in GA is just the vector scaled to the reciprocal of its length, which for the basis vectors is just themselves. The biggest problem is just that it's never mentioned when initially teaching quaternions, while bivectors have a clear relation to the vectors that formed them.

    • @blinded6502
      @blinded6502 2 года назад +2

      Actually, considering the fact that quaternions are usually constructed from rotation-axis pseudovector:
      i = yz
      j = xz
      k = xy
      3d rotors are not 4d. I mean, you could represent them as 4 quantities along 4 different axes, but.... Why?

  • @Psykorr
    @Psykorr 2 года назад

    Nice video!

  • @roygalaasen
    @roygalaasen 4 года назад +8

    I am confused. Not by your excellent video, but because I was already subscribed to your channel. That means there were excellent videos here from before. But this is the only video here and it was released 30 minutes ago. Did you delete all of your old content? That is a bit sad because although I don’t remember it off the top of my head, I did subscribe because it was good, and if it is deleted, good content has been taken away from this world.

    • @ddegn
      @ddegn 4 года назад +1

      I initially felt like you described. I checked out his website and felt a bit more at ease. There's lots of great stuff on his website.
      Apparently this is an update of an older video. I also don't recall how many videos he had, I just remember being impressed by the quality of the previous video.

    • @roygalaasen
      @roygalaasen 4 года назад +1

      Duane Degn if I remember correctly, this is the channel I commented that it was sad that he didn’t make any more videos since they were few, but really good and his last video was like 3 years ago or something. In that case we are in for a lot of goodies coming up in the future.

    • @ShankarSivarajan
      @ShankarSivarajan 4 года назад +4

      This is the Miegakure guy. That's almost certainly why you were subscribed.

    • @roygalaasen
      @roygalaasen 4 года назад +1

      Shankar Sivarajan oh it is? I am certain that was not the reason, but I subscribe to loads of math channels and also watching a few videos of that game, RUclips algorithm probably thought to suggest videos from this channel, and I took the bait and subscribed. Thanks for the connection though!

    • @marctenbosch
      @marctenbosch  4 года назад +4

      My other videos are unlisted, they are old and I embed them on the related articles on my website.

  • @budasfeet
    @budasfeet 4 года назад

    One quaternion concept i never understood was quaternion averaging, is there any reference to that for rotor? I guess the algorithm will probably be exactly the same but I hope rotor can provide better explanations for averaging rotors.

    • @marctenbosch
      @marctenbosch  4 года назад +4

      I am not sure it's better. The way I would think of it is thinking about the 2D case, just looking at two points on a circle, taking the average then normalizing to get back on the circle. (Each point on the circle clearly corresponds to a rotation.)

  • @charlesbrowne9590
    @charlesbrowne9590 2 года назад

    At 13:15, Ra(v) belongs in the first quadrant. Vectors v|| and v_| are swapped in the picture.

    • @charetjc
      @charetjc 2 года назад

      The reflection isn't over vector A, it's over the plane that A is normal to. Also, parallel and perpendicular notation implies a relationship of vector V with something else. If the author meant the reflection plane, then the notation is correct as is.

  • @daveyhu
    @daveyhu 2 года назад +1

    Is there a preferably c++ library out there implementing these rotors where one could see them in action and most importantly assess the performance characteristics of working with them over quaternions?

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

      See the source code attached to the article: marctenbosch.com/quaternions/code.htm

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

      There are quite a few libraries like that on the Bivector website

  • @budasfeet
    @budasfeet 4 года назад +2

    What are the cases when we need more than 4 dimensions, where we use 4d to represent 3D in both quaternion and rotor?

    • @marctenbosch
      @marctenbosch  4 года назад

      Not sure what you mean

    • @budasfeet
      @budasfeet 4 года назад

      Marc ten Bosch because rotors can be extended to higher dimensions, so I was wondering what are the use cases of higher dimensional geometric computation?

    • @marctenbosch
      @marctenbosch  4 года назад +7

      @@budasfeet Things I am working on: miegakure.com and 4dtoys.com Also any computations in higher dimensions sometimes need rotations.

    • @budasfeet
      @budasfeet 4 года назад +6

      Marc ten Bosch didn’t know these games were made by you!

    • @porky1118
      @porky1118 2 года назад

      Also for spacetime physics this might be useful.
      Or you can use 5D to represent 3D using conformal GA.

  • @Euquila
    @Euquila 2 года назад

    You definitely taught me some new shit. I feel further out of the knowledge cave. Thanks!

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

    In solid mechanic there is what we call the Mohr circle where the transformations double the angle !

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

    Can bivectors be used for smoothly interpolating rotations?

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

      Yup! For the same reasons that quaternions are good for spherical interpolation.

  • @anuman99ful
    @anuman99ful 2 года назад

    Wait, in 16:30, isn't the (xy)(yz) product inconsistent with the cross product right-hand rule? Because the result yields xz which is what we would refer to -j (unit basis vector notation) in a cross product fashion, however, the product suggest that is k x i, which is j.

    • @angeldude101
      @angeldude101 2 года назад

      I wouldn't be able to say because I have no idea which direction "j" rotates in, where as (xy)(yz) clearly is oriented in the direction from x to z. Setting i = x* = yz, j = y* = zx, k = z* = xy
      ij = yzzx = yx = -k, So clearly the simple way I defined them doesn't align with the quaternions exactly, even if I made them with a right handed dual operation. The best guess I can give is that the quaternions aren't actually right handed, and were instead picked to satisfy ijk = -1. If I redo my setup, but with j = yx, then suddenly the ijk = -1 identity works again, though flipping any of the unit bivectors should give the same result.

  • @erickweil4580
    @erickweil4580 4 года назад +3

    I was working with 4D geometry and rotations, And then to rotate around a arbitrary 2d plane, is by defining the plane as a basis with x and y lying in the plane, but z and w outside ( all orthogonal to each other ), then the point is projected to this basis, rotated xy in 2d, and projected back. ( change basis with dot product, go back multiplying components by the vectors )
    Is correct to say that you do a similar thing, I mean, change the basis, apply a operation, then reverse the basis change?
    Is this why the operation is: ba v ab
    Quaternions also do the same thing.
    Idk but I see a pattern

    • @marctenbosch
      @marctenbosch  4 года назад +5

      Yeah, all "sandwich" product like that are changes of basis.

  • @blinded6502
    @blinded6502 2 года назад

    After a year, I finally can say that this article shows geometric algebra from a very weird perspective. It simply attempts to find the appropriate algebra for what it's trying to do, instead of explaining it from bottom up.
    GA actually is all about reflections. When we reflect something twice along different vectors, we can rotate said object. If those reflections are offset, we can translate objects.
    Geometric product combines two or more reflections into a single transformation. Inner and outer product are just cases of geometric product, when only reflections parallel/orthogonal to each other are considered. In first case reflections are cancelled out, in second one they are accumulated into multiaxial reflections.
    That was a rough explanation of how GA works. It's truly an amazing tool, and a very intuitive one at that. It had simplified all of sophisticated linear algebra problems I've had to very tiny equations with very transparent logic.

    • @user-hh5bx8xe5o
      @user-hh5bx8xe5o 2 года назад

      Actually, while the sandwich product make it easy to work with reflections in GA, the geometric product is more subtle as it involves a change in the dimensionality of the objects it acts on.
      For example, on vectors, it collapses to a scalar AND raises to a bivector. Thus seen functionally the action of the geometric product is quite different from a reflection.

    • @blinded6502
      @blinded6502 2 года назад

      @@user-hh5bx8xe5o Sum of scalar and bivector is a rotor (a bireflection).

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

      @@user-hh5bx8xe5o The geometric algebra _composes_ reflections. It doesn't directly _perform_ them. That's the job of the sandwich product. That said, the sandwich product is implemented in terms of the geometric product, so it effectively gives a transformation that first performs one, then another, and then undoes the first transformation, leaving only the result of the middle transformation, but as though it was transformed by the outer transformation.

  • @Plamenko8L
    @Plamenko8L 2 года назад

    There is an error in the reflection calculation. Formulas for the parallel and perpendicular components were exchanged. The correct formula for Ra(v) is "2(v.a)a - v". I.e. the whole thing is negated.

  • @geoffreystearns1690
    @geoffreystearns1690 2 года назад +1

    Can rotors be orthogonalized? Due to the discrete nature of digital computing, quaternion orthogonality will drift over time as their components get truncated in computation. They therefore have to be reorthogonalized after a while for precision results. Are rotors subject tot he same problem?

    • @JivanPal
      @JivanPal 2 года назад

      Of course, because the problem you're describing is one of computer precision, not underlying mathematics. Rounding errors are a problem in every aspect of computational mathematics. Re-orthogonalisation is just checking and enforcing a constraint over time (in this case, that the angle subtended is 90°) to make sure that rounding errors don't compound too much.

    • @areadenial2343
      @areadenial2343 2 года назад

      While a bit far off, computers using balanced ternary instead of binary computation could be useful for this. In balanced ternary, truncation is the simplest way to round to the nearest number, so rounding errors accumulate much more slowly.

  • @Alexander_Sannikov
    @Alexander_Sannikov 2 года назад +1

    I don't see an explanation of how exactly you define a geometric product, and more specifically, how do you add its scalar part with its bivector part. Because if you define geometric product as an operation that acts on two vectors and produces a scalar + bivector, how do you later claim that reflection is R(v, a) = v - 2*(v*a)a = ava, where you have a vector on the left side of the equation and a (bivector+scalar)*vector=trivector on the right side?

    • @user-hh5bx8xe5o
      @user-hh5bx8xe5o 2 года назад +4

      In the video, the geometric product is defined on vectors by splitting it into the symmetric part and antisymmetric part. The first is identified with the dot product and the second with the exterior product.
      Note that conceptually, the geometric product on vectors is the sum of a contraction (the output has a lower dimension than the inputs) and an extension (higher dimension than the input).
      In practical terms, the geometric product can be computed from the relationships of the basis vectors. In the Euclidean case described in the video, a vector multiplied by itself is 1 and multiplied by any other basis vector is 0 (Kronecker's delta). Other elements (bivectors, trivectors, ...) products can be computed by the rules on vectors and the antisymmetry of the basis bivectors (e1*e2 = - e2*e1) which allows to swap terms to cancel duplicates (e2*e1*e2 = - e2*e2*e1 = - e1).

    • @stefanvasilev2013
      @stefanvasilev2013 2 года назад

      A valid remark. As already noted, it's defined as a sum but the sum is between different entities. To make that valid you need to introduce another space where both entities live, which was not done in the video, losing rigorousness. Another miss was the lack of proof why this product is invertible, there were only (questionable) heuristics. Describing the whole thing consistently would've been more work than just explaining how to use quaternions in a clear way, so it would've defeated the purpouse of the video I guess :)

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

    where does the 'a' in a 3D rotor come from?
    edit: after skimming the comments in the code, it is the rotation around the bivector defined by the latter 3 elements.

  • @Shamstabrezkhan
    @Shamstabrezkhan 2 года назад

    what tools did you use to create this video?

  • @jcbahr
    @jcbahr 2 года назад

    Kept expecting you to bring up the Hodge star
    (It's the duality map between (n-k)-vectors and k-vectors in Rn. So in 3D, it's the map between bivectors and vectors. And in 2D if you want, it includes the map between bivectors and scalars (0-vectors))

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

      It was outside of the scope of this video! If I made another video I would talk about it for sure!

  • @patrickdoyle4581
    @patrickdoyle4581 2 года назад +1

    10:58 - The geometric product seems more like a tuple than a sum, at first glance. With complex numbers, a sum makes sense because of how arithmetic works out (starting with i*i = -1). I'm not seeing a similar feature with the geometric product; is there one?

    • @ahusky4498
      @ahusky4498 2 года назад +2

      If you want to be technical, the addition of different graded elements is actually a direct sum (a way to add vector spaces together). So you can establish vector spaces for scalar, vectors, bivectors and etc. Then from there you can define define geometric product and its properties

    • @porky1118
      @porky1118 2 года назад +1

      any plane of basis vectors has the same properties as "i". Just replace i by the plane.
      For example if your basis vectors are x and y, then this is true:
      xy * xy = -1

    • @ahusky4498
      @ahusky4498 2 года назад

      @@porky1118 that is also assuming the basis vectors both of positive signature (or both negative) and the product is normalized

    • @porky1118
      @porky1118 2 года назад

      @@ahusky4498 I used x and y as used in the video.
      Normally, x and y are called e_1 and e_2

    • @danielm6846
      @danielm6846 2 года назад +1

      Any one of these bivectors also squares to -1 if that helps. A bivector and a scalar together is algebraically the same as a complex plane.

  • @scotth.hawley1560
    @scotth.hawley1560 2 года назад

    Very much enjoyed the video and the accompanying interactive document. Thank you for sharing. One thing that isn’t clear to me is why the pair of reflections give a rotation of twice the angle between a & b. I can see that this appears to be the case in the interactive graphs, but where is this proven? The speech “it turns out that…” is presumably a stand-in for such a proof but I’d like to see how to actually do it.

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

    How about tools asociated with the rotors - Numerical Inegration, Differentiation, Spherical Interpolation between two rotors, Computing angular rates from the rotor's time derivative? Are they well defined and present in the literature?

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

      clifford algebra is centuries old why would it not

  • @losiu998
    @losiu998 2 года назад +3

    6:51 - B_xy looks like determinant of the 2D matrix, where columns are 2D vectors, coincidence? Of course not :)

  • @0dWHOHWb0
    @0dWHOHWb0 2 года назад

    Isn't that table at 12:10 tautological? Is that supposed to be e.g. xy = x^y instead of just the obvious xy = xy currently in the table?

    • @JivanPal
      @JivanPal 2 года назад

      The upper-right half is self-evident, yes. You cannot express these vector products in terms of anything simpler, so they stand as is. If you wanted, you could give them unique names, but then you're back in quaternion land: name them *i, j, k* ! The point of the table is to demonstrate self-inverse and anti-commutativity, i.e that xx = 1, and xy = -yx.

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

    I actually understand the quaternion stuff and it's not as complicated as it seems, but yes geometric algebra is easier to learn and work with

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

    Comment on 7:30, components of a bi-vector: aren't bi-vectors something of a "directional" surface, that contain also a information about the direction of rotation rather then just area of the surface? Is this information then contained in the individual contributions in the unit bi-vectors?

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

      Sorry for the late reply: yes, for example, you can see (earlier in the video) how in 2D I change the color of the bivector from blue to green when the rotation goes from clockwise to anti-clockwise. It is a "signed" area. In 3D you would have to multiply all three bivector components by -1 to represent the opposite rotation, just like negating a vector, which is equivalent to -(a^b) = b^a

  • @ilafya
    @ilafya 2 года назад

    You are the man

  • @a.osethkin55
    @a.osethkin55 2 года назад

    Amazing

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

    True, there is only one plane in 2D to rotate within, however there are also infinitely many points in 2D to rotate around, unless you're restricting yourself to rotations around the origin, in which case the origin itself is the only point to rotate around. Also who said anything about rotating around a line? 2D lines are mirrors, not rotation axes.
    Extending to 3D, which this does give back the idea of an "axis of rotation" (which _is_ a line when in 3D), I'd still argue that they're more clear than quaternions since the direction is still encoded in how you write the basis: xy, yx, yz, or zy instead of i or -i.

  • @2fifty533
    @2fifty533 Год назад

    so, what are quaternions _actually_ useful for then? or are they essentially redundant since this exists

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

      Quaternions are useful for making rotors seem more complex than they really are, so that when you demonstrate your understanding of quaternions, you appear smarter than if you had communicated in terms of rotors. They're also useful for praising William Rowan Hamilton and his act of vandalism.
      In terms of actually doing math, there's nothing that quaternions can do that rotors can't, because 3D rotors effectively _are_ quaternions just with a more clear derivation and more explicit basis.

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

      @@angeldude101 late reply but i think it's a bit harsh to call hamilton a "vandal"
      without him, clifford algebras wouldn't even exist, Cl(3, 0, 0) was created from quaternions

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

      @@2fifty533 I mean, he literally was one. The site of his vandalism has literally become a historical site.

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

    Geometric algebra is a very beautiful area of modern mathematics. I should be taught on all undergraduate courses.

  • @DrakeLarson-js9px
    @DrakeLarson-js9px 2 месяца назад

    Your instinct was sound.. it is somewhat overly complicated ... it is rotation (and how to describe?) and Hamilton 1843 notice of the twirling vortexes of water under the bridge was the foundation of this.. which is useful for 'creative projections' ... (This video is a ton of information in under 20 minutes, Congratulations.)

  • @budasfeet
    @budasfeet 4 года назад +1

    Why do you call outer product in your code wedge product?

    • @marctenbosch
      @marctenbosch  4 года назад +5

      These names are used somewhat interchangeably

  • @zaq1320
    @zaq1320 2 года назад +5

    This is great! Some really cool vector math I didn't know about. So, while I have no doubt that these work, I'm struggling to understand how they would serve artists better in a 3D program. The math being prettier under the hood doesn't mean much if it doesn't actually improve the production process, and I can't actually tell exactly what implementing these with all degrees of freedom would look like. Say your A vector is just fixed to some arbitrary unit axis (of the artist's choice). Makes sense. The artist now has to define another point in 3D space, with three numbers we can then normalise to the B vector. Great. I struggle to understand how this doesn't just amount to a "swing" rotation, which we then add a "twist" rotation to afterwards.
    Swing and twist rotations are already implemented in blender (not sure about maya), and are very useful - if that's what an implementation of rotors shakes out to, then we already have 'em, although only in the drivers. They're great! They are computed from quats, though. If rotors kind of naturally decompose to swing and twist that's convenient for the developers, which is nice I guess. For an artist I don't imagine it would make too much of a difference.

    • @JivanPal
      @JivanPal 2 года назад +2

      *_"I'm struggling to understand how they would serve artists better in a 3D program."_* - It doesn't, that's the whole point of the video. Quaternions work just fine, and the author points out that they are isomorphic to rotors. That is, they're functionally one and the same. The point of considering rotors is that they are more intuitive to work with. It's a mathematician's interest, not a software engineer's. If you were to implement both quaternions and rotors in code, the implementations would be equivalent.
      If, as a programmer, you are working with a physics library that implements its functionality with either quaternions or rotors, but abstracts that away from you via an API that makes no mention of either, then the underlying math is not a concern. However, if you are working directly with quaternions or rotors, then the latter is most likely favoured, because they are easier to intuit about.

    • @zaq1320
      @zaq1320 2 года назад +1

      @@JivanPal Yeah, I figured it seemed like a purely mathematical/software engineering exercise and again, from a back end perspective this is really cool. The title does say we should remove quaternions from every 3D engine, though, I think it’s not unreasonable to infer a claim about improving the work of 3D engine users from that, right? I’m just always on the look out for better ways to handle rotations as a technical artist.

    • @JivanPal
      @JivanPal 2 года назад +4

      @@zaq1320 *_"The title does say we should remove quaternions from every 3D engine, though, I think it’s not unreasonable to infer a claim about improving the work of 3D engine users from that, right?"_* - Ehh, semi-clickbait. Seems to me like the author is merely advocating that such a change should take place because computer physics/graphics courses should be teaching students about rotations from the rotor perspective rather than the quaternion perspective, in order to aid intuition and understanding as to what these things are and why they work.
      *_"I’m just always on the look out for better ways to handle rotations as a technical artist."_* - You're probably not going to find it! The APIs and optimised hardware already exist, nothing better will appear (at least not anytime soon; mathematics has pretty much got this area covered already).

    • @joojaa3927
      @joojaa3927 2 года назад +3

      For an artist this gives a way for you to better visualize the rotation. Not well but better. This in turn means that we can eventually work out a more workable way of controlling the rotation with animation curves. Since eventually the visualisation will lead to a understanding. Theres no way you can directly manipulate the quaternion values in a meaningful way.
      In addition its hard to work with quaternion in physics context. So that could mean better user interfaces for inverse simulations. Inverse simulations would allow us to have better controllable simulations in conjunction to keyframes.
      But ultimately having more of your programmers actually understand the math gives ground for more tools, more tries and better successful tools for you to use.

    • @joeedh
      @joeedh 2 года назад +1

      @@JivanPal Honestly I'm not convinced that either approach is particularly intuitive. I don't care if geometric algebra makes more sense in >3 dimension, for 3d it seems to add complexity without value.

  • @MrGerdbrecht
    @MrGerdbrecht 2 года назад

    I know that 2 Reflections give a Rotation, because of quaternions, ergo i dont see any difference of your rotor to a normal quaternion rotation. Did you explain reflection in terms of quaternion mul?

    • @blinded6502
      @blinded6502 2 года назад

      Quaternions are same as rotors. But quaternions are explained in wrong terminology.

  • @ongamex
    @ongamex 3 года назад +2

    I just do not see why is this better/different form quaternions. It is a different name for the same thing. Do you have a coded example, where I can see the differences in use (not the implementation or Rotors, for what I saw it is just quaternions with different wordings)?
    One thing I always wanted to to do with quats is to apply a "partial" rotation, something like "take N% of the rotation represented by q1 and apply it to q0". Is this possible with rotors? With quats you basically have to extract the axis and the angle and then contruct a new quaternion.
    Can a rotor represents rotation outside of [0;360deg], for example a 720deg rotation, where I can take N% of it?
    I just don't see why and how this is better then the established quaternions. It is easy to extract the plane and the angle of rotation from a quat. Multiplication and inverses/conjugates are quite easy.
    lerp/slerp-ing them is easy.

    • @marctenbosch
      @marctenbosch  3 года назад +2

      It's better because rotors don't come out of nowhere like quaternions do. Here's the code: marctenbosch.com/quaternions/code.htm

    • @porky1118
      @porky1118 2 года назад +1

      Quaternions and 3D rotors are just the same thing. There's nothing you can do with 3D rotors, that you can't do with quaternions by themselves. There are two advantages of rotors.
      1. Rotors are dimension generic.
      So you could write some utility method for rotors in general and it works for rotors of any dimension.
      2. If you also have other GA types like bivectors, rotors show their true power.
      For example you can create a torque by mutliplying two vectors using the outer product and get a bivector, which you use as torque. Then you compute the exponential function of that bivector and get a rotor, which you use to rotate the object. Then you multiply the rotor by another rotor to change the view.
      So rotors aren't that special themselves, but GA is.

    • @ongamex
      @ongamex 2 года назад

      @@porky1118 Aha, that dimension generic thing is the key. Thanks for the clarification. Maybe If I delve more into physics they will start making sense.

    • @porky1118
      @porky1118 2 года назад

      ​@@ongamex A simple example in physics, why you would prefer GA is torque (angular momentum).
      In 2D you would probably represent angular speed using a scalar, in 3D you would use an axis vector, where the magnitude represents the velocity.
      In GA, you would just use a bivector. A 2D (x, y) bivector has only one component (xy), so it's similar to a scalar.
      In 3D (x, y, z) it has 3 components (xy, xz, yz), so it's similar to a axis vector.
      And in 4D (x, y, z, w) it has 6 components (xy, xz, xw, yz, yw, zw). You might need it for space-time (relativity).

    • @porky1118
      @porky1118 2 года назад

      ​@@ongamex A simple example in physics, why you would prefer GA is torque (angular momentum).
      In 2D you would probably represent angular speed using a scalar, in 3D you would use an axis vector, where the magnitude represents the velocity.
      In GA, you would just use a bivector. A 2D (x, y) bivector has only one component (xy), so it's similar to a scalar.
      In 3D (x, y, z) it has 3 components (xy, xz, yz), so it's similar to a axis vector.
      And in 4D (x, y, z, w) it has 6 components (xy, xz, xw, yz, yw, zw). You might need it for space-time (relativity).

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

    Question:
    How many degrees of freedom an object can manifest at the same time? For example, a sphere is spinning clockwise and moving forward at the same time, i.e. it’s using 2 out of 6 degrees of freedom, can it have more?

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

      In N-dimensions, there are N choose 2 degrees of freedom in choosing an axis of rotation, but a given rotation can have up to floor(N/2) distinct axes being rotated around at once.
      In your example, representing translation as a kind of rotation requires an extra projective dimension, so it acts like 4D in this case, with 6 degrees of freedom for choosing an axis, and 2 distinct axes that it's rotating around, one for spinning around its center, and one acting as an "axis of translation." Since floor(4/2) = 2, any subsequent rotations you try to add will just change the two existing axes rather than add any new ones.

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

      @@angeldude101
      so the maximum is 2? Only 2 can be engaged simultaneously be it positive or negative while the other 4 will be 0 ?

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

      @@Troinik Uh... No? You can still rotate around any plane in 4D space whether or not it's aligned with the coordinate axes, which gives an infinite amount of options, but trying to rotate around any more than 2 independent axes will always collapse them down to 2, even if they might be around different axes than the four rotations you were composing.

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

      @@angeldude101
      I think i understand, but lets do a somewhat practical example.
      We have an object that moves 5 cm on Y axis, our measuring devices show:
      X - 0
      Y - 5
      Z - 0
      X(spin) - 0
      Y(spun) - 0
      Z(spin) - 0
      We start again but this time the object gets a spin on Z axis of 3 rpm and it’s moving 7 cm on Y axis, our measurement devices will show:
      X - 0
      Y - 7
      Z - 0
      X(spin) - 0
      Y(spin) - 0
      Z(spin) - 3
      In this case the object uses 2 out of 6 degrees of freedom simultaneously.
      My question is how many (what is the maximum) degrees of freedom an object can use simultaneously? 2 out of 6 ? 3 out of 6 ? Or all 6 ?

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

      @@Troinik 7e02 + 3e12 = (7e0 + 3e1) ∧ e2, so that's actually using only 1 of the 2 available independent axes, even if said axis isn't aligned with any of the 6 basis axes.

  • @thygrrr
    @thygrrr 7 месяцев назад +1

    Thank you for this great perspective, but especially in the middle, I fail to connect the dots and have no mental model whatsoever of your bivector, numerically. I always thought it is the cross product.
    I think you could have provided the actual formula for the bivector for the 3D case. Numerical only, default unit basis in 3 dimensions ("xyz", or index 1 to 3, or 0 to 2 for us coders).
    Is it the cross product in 3d now, or IS IT NOT? Your formula looks like it's self referential, each outer product requiring another outer product multiplied with the components of the cross product. 7:56 How do we even read the bottom equality? Or is it a formatting error and the wedge products on the right side are subscripts?
    And which one do we use? It appears like this depends on the handedness of our coordinate system but you just skipped over it. 😢 Or is the first + in the bottom equation at 7:56 a typo?
    From the looks of it, it's also not clear whether trig functions are needed for this wedge notation or not. Can I express a definitive rotation from a into b (around the axis axb) without first calculating the angle 2alpha, just by using the two unit vectors a and b?
    As it stands now, I find the exponential map / quaternion representation of rotations more intuitive, and that's really saying a lot.

  • @maximeeuziere
    @maximeeuziere 4 года назад +2

    I wish there was a concrete code exampe of how to use them

    • @marctenbosch
      @marctenbosch  4 года назад +21

      The article has the code: marctenbosch.com/quaternions/code.htm

  • @christelleaugustin1695
    @christelleaugustin1695 2 года назад

    Can anyone explain please why, at 6:35 we ADD the componenents of the vectors and multiply them with "x" and "y".. What? I don't get it ;(

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

      it’s like saying “take three steps east and four steps north” where east is the x unit vector and y is the north unit

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

      This is just another way to write down the vector. a_x is how much the vector moves along the x axis, and a_y is how much it moves along the y axis, so a_x * x is the vector along x that moves a_x units along the x axis. a_x is a number and x is the vector that corresponds to the x axis. Then when you sum them together you get the vector that moves in both x and y. So the vector (a_x,a_y) can be written down as a_x*x + a_y*y

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

      @@marctenbosch Ah! Thanks. It makes total sense now.

  • @you74674
    @you74674 4 года назад

    I have a question about the choice of the three basis planes. Why choose x∧z instead of z∧x as one of the basis plane? This is the only part that looks arbitrary to me.
    I think mathematically it doesn't matter since all the signs will cancel each other(which means there will be 8 possible set of basis planes, I guess?), but using z∧x should make the equation exactly the same as cross product. (in section 2.5)

    • @marctenbosch
      @marctenbosch  4 года назад +1

      Yeah it is arbitrary. I chose lexicographic order... I guess because it is obvious to remember, over wanting to preserve the equation of the cross product. Also worth noting that there's always some arbitrariness in choosing a basis (already for vectors I mean).

    • @you74674
      @you74674 4 года назад +1

      @@marctenbosch
      Ok, I understand now.
      I still prefer z∧x though, since it gives the same "direction" for all basis. (in the graph in section 2.2)
      (it's kind of similar to the right hand rule, maybe?)

    • @marctenbosch
      @marctenbosch  4 года назад +2

      @@you74674 It's totally the right hand rule, except the understandable non-arbitrary version :)

    • @you74674
      @you74674 4 года назад +1

      @@marctenbosch
      If I didn't mess up anything, I think I have some new discovery.
      Let's assume we're finding a rotation from unit vector u to unit vector v, and start from the representation of rotor:
      a+Bxy x∧y+Bxz x∧z+Byz y∧z
      =a+Bxy x∧y+Bzx z∧x+Byz y∧z (use z∧x instead of x∧z, so replace Bxz with Bzx, where Bzx=-Bxz)
      =a+(Bxy, Bzx, Byz) . (x∧y, z∧x, y∧z) (. is dot product)
      =u . v + (u × v) . (x∧y, z∧x, y∧z) (× is cross product)
      =cosθ + sinθ A . (x∧y, z∧x, y∧z) (A is the axis of rotation)
      =cos(φ/2) + sin(φ/2) A . (x∧y, z∧x, y∧z) (φ=2θ, here I changed the symbol since the actual rotation angle is 2θ)
      Which is exactly the same formula for quaternion.
      So this means that we don't even need to change any code to use rotor!
      But I still hope that one day we can replace quaternion with rotor(or Rotor3 in actual code), since this name is much shorter and much more trivial.

  • @antoinefortin1386
    @antoinefortin1386 4 года назад +2

    Ok this is something !