Skip to content

Instantly share code, notes, and snippets.

@sw17ch
Created August 30, 2014 00:38
Show Gist options
  • Select an option

  • Save sw17ch/007d2f5cbc36e012378e to your computer and use it in GitHub Desktop.

Select an option

Save sw17ch/007d2f5cbc36e012378e to your computer and use it in GitHub Desktop.
An IRC conversation between me and fishcorn about quaternions and my lack of understanding thereof.
sw17ch: today i'm trying to figure out quaternions and if they are different from a normal vector and a rotation around that normal...
[3:53pm] jcaudle_ is now known as jcaudle.
[3:53pm] oliffia: ive made maybe a dozen games before, none particularly big
[3:53pm] oliffia: or good :)
[3:53pm] vanila: sw17ch, I know a nice way to think about them with analogy to normal complex numbers if you like
[3:54pm] sw17ch: vanila: i think part of my problem is the complex numbers
[3:54pm] sw17ch: euler angles seem to work well for me
[3:54pm] sw17ch: and i'm trying to figure out the advantage in quaternions
[3:54pm] sw17ch: or why complex numbers come into play
[3:54pm] vanila: the main advantage of quaternions is that they don't suffer from gimbal lock, which the axis-angle approach does
[3:55pm] vanila: I mean euler-angle approach
[3:55pm] sw17ch: i need to go look up gimbal lock
[3:55pm] erasmas: oliffia: cool. if you have a website with them (that you can share) I'd like to see, but I understand if not
[3:56pm] oliffia: http://dogue.in/ heres my most recent scala ones
[3:56pm] welpbot: Title: dogue.in
[3:56pm] briennetheblue left the chat room. (Quit: Page closed)
[3:56pm] jcaudle is now known as jcaudle_.
[3:56pm] sw17ch: vanila: woa, so that's a new concept for me
[3:56pm] oliffia: my haskell game is on my github too
[3:57pm] erasmas: oliffia: awesome. thanks. about to take off now for a long weekend but I will check it out
[3:57pm] vanila: it's a big proble if you want to be able to freely move around in 3D with the mouse or rotate a trackball or something
[3:57pm] sw17ch: vanila: http://en.wikipedia.org/wiki/Gimbal_lock <— reading this isn't helping me much
[3:57pm] welpbot: Title: Gimbal lock - Wikipedia, the free encyclopedia
[3:57pm] roboguy_: sw17ch: glancing at it, this looks like a good explanation https://www.youtube.com/watch?v=zc8b2Jo7mno
[3:57pm] oliffia: erasmas: :D happy to help if i can if you have any questions
[3:57pm] roboguy_: sw17ch: a visual explanation is the way to go for understanding gimbal lock
[3:57pm] sw17ch: vanila: oddly enough, i'm dealing with robots
[3:58pm] __builtin_yuno: hello !haskell
[3:58pm] RchrdB: Hi __builtin_yuno. ^_^
[3:59pm] roboguy_: sw17ch: the short version is that, in certain rotation configurations using Euler angles, you lose a degree of freedom
[4:00pm] charliesome joined the chat room.
[4:02pm] sw17ch: roboguy_: wow, this helps explain a lot
[4:02pm] fishcorn: sw17ch: here's a math.sx answer I wrote about gimbal lock a while ago: http://math.stackexchange.com/a/1858/950
[4:02pm] jcaudle_ is now known as jcaudle.
[4:03pm] roboguy_: sw17ch: the Euler angle method has that problem but quaternions don't
[4:03pm] sw17ch: but when we say "lose a degree of freedom" what we mean is that there are some changes to just one axis that may require rotations of multiple axes
[4:03pm] erasmas left the chat room. (Quit: leaving)
[4:03pm] fishcorn: sw17ch: more or less
[4:04pm] vanila: and I'd be happy to explain about complex numbers & quats if you have any questions :)
[4:04pm] fronx left the chat room. (Remote host closed the connection)
[4:05pm] sw17ch: so, here's what i undersatnd of quats so far
[4:05pm] sw17ch: (thank you, vanila and fishcorn and roboguy_ )
[4:05pm] sw17ch: a quat is basically a vector
[4:05pm] roboguy_: no problem!
[4:05pm] sw17ch: and a rotation around that vecotr
[4:05pm] sw17ch: right?
[4:05pm] sw17ch: well
[4:05pm] sw17ch: maybe not
[4:06pm] vanila: you can convert axis-angle rotation into a quaternion
[4:06pm] sw17ch: okay, my real problem
[4:06pm] vanila: but it's something slightly different
[4:06pm] sw17ch: I have an inertial measurement unit. :)
[4:06pm] sw17ch: it's a small, _expensive_ little device that tells me where it is oriented in space
[4:06pm] sw17ch: it reads out a few things to me
[4:06pm] sw17ch: 1) a translation from an origin
[4:06pm] sw17ch: which is, as expected, a 3d vector
[4:06pm] sw17ch: and 2)
[4:07pm] sw17ch: a set of euler angles (3)
[4:07pm] sw17ch: and i'm trying to imagine what gimbal lock looks like to the IMU
[4:07pm] sw17ch: any way
[4:08pm] jcaudle is now known as jcaudle_.
[4:08pm] fishcorn: sw17ch: this wp page helped me a lot: http://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions
[4:08pm] welpbot: Title: Rotation formalisms in three dimensions - Wikipedia, the free encyclopedia, http://tinyurl.com/coqwkkk
[4:10pm] fishcorn: sw17ch: gimbal lock is an instantaneous non-continuous change in angle of one of the axes
[4:10pm] fishcorn: (since gimbals can't actually physically do that, they "lock")
[4:11pm] sw17ch: vanila: fishcorn's point highlights something else i can't figure out. why does gimbal lock apply to computers?
[4:11pm] sw17ch: or to virtual 3d environments?
[4:11pm] fishcorn: sw17ch: find one of the youtube videos
[4:11pm] sw17ch: fishcorn: i've just watched several. they all talk about physical analogies
[4:11pm] sw17ch: like cameras on rings
[4:11pm] fishcorn: ok let me find one
[4:11pm] sw17ch: which i totally get why that matters
[4:12pm] sw17ch: but for a computer, there's no reason for the rings to be concentric
[4:12pm] sw17ch: right?
[4:12pm] sw17ch: oh, wit
[4:12pm] sw17ch: oh, wait
[4:12pm] sw17ch: if it's described as three rotations,
[4:12pm] sw17ch: then you're rotating the entire body in its current state around that fixed axis..
[4:13pm] sw17ch: okay, so i'm starting to get the picture that the desired thing in that sort of an environment is a way to apply a translation on the rotated object relative to itself rather than rotated in reference to some fixed axis
[4:14pm] sw17ch: sorry, a rotation, not a translation, to an already rotated object
[4:14pm] vanila: yes, quaternions let you compose rotations in a clean way - euler angles don't because of this gimbal issue
[4:15pm] sw17ch: vanila: okay, composition.
[4:15pm] sw17ch: ah! so that's why quaternion operations are non-commutative
[4:15pm] sw17ch: wait, i thin
[4:15pm] fishcorn: sw17ch: yes
[4:15pm] sw17ch: i gotta think through that
[4:15pm] fishcorn: they are noncommutative
[4:15pm] sw17ch: but applying the same quat rotation in the wrong order is not going to get you to the same spot
[4:16pm] sw17ch: or whatever i meant by that
[4:16pm] vanila: exactly! because when you are rotating things around different axis.. it matterns what order you do it in
[4:16pm] jfischoff left the chat room. (Ping timeout: 245 seconds)
[4:17pm] tworkin left the chat room. (Quit: Leaving.)
[4:17pm] sw17ch: vanila: okay, there's the next question
[4:18pm] sw17ch: is a quat rotation locked to a single axis?
[4:18pm] sw17ch: so, if we have a reference object with an orientation
[4:18pm] vanila: you can represent any rotation using a unit length quaternion
[4:18pm] sw17ch: hmm
[4:18pm] sw17ch: let me rephrase
[4:18pm] sw17ch: the quat will take the reference object
[4:19pm] sw17ch: and if we picked a surface normal
[4:19pm] sw17ch: to the object
[4:19pm] sw17ch: a quat rotation could be done such that the normal would draw an arc that, when projected onto a 2d surface from above would be straight
[4:20pm] sw17ch: lol
[4:20pm] sw17ch: no matter what the initial object orientation relative to the environment was in
[4:21pm] sw17ch: as opposed to having to deviate the arc's path from something other than straight to achieve the new orientation
[4:23pm] vanila: I'm having trouble visualizing and understanding that
[4:24pm] sw17ch: haha
[4:24pm] sw17ch: yeah
[4:24pm] sw17ch: sorry
[4:24pm] sw17ch: umm
[4:24pm] sw17ch: so lets see
[4:24pm] sw17ch: i'm standing in Washington State, USA
[4:25pm] sw17ch: and there's a rotation you could perform on me that would get me to "berlin"
[4:25pm] sw17ch: with euler angles, that rotation might take me someplace other than as the crow flies to berlin (immagine a really strong crow)
[4:25pm] sw17ch: the "as the crow flies" property
[4:26pm] sw17ch: or, "only rotating along one axis" when you pick an arbitrary axis centered on the object
[4:26pm] fishcorn: sw17ch: this demonstrates pretty well the gimbal lock issue in animation: https://www.youtube.com/watch?v=hdZT9C-pOLs#t=526
[4:27pm] sw17ch: fishcorn++
[4:29pm] sw17ch: fishcorn: so the underlying problem is that we're dealing with matricies, right?
[4:30pm] fishcorn: sw17ch: not really
[4:30pm] sw17ch: :|
[4:30pm] fishcorn: it's more of a differential geometric problem
[4:30pm] fishcorn: you can do quaternion multiplication with matrices, so matrices aren't really the issue
[4:31pm] sw17ch: then i'm still missing whatever property it is about quaternions that gets us out of that mess
[4:31pm] mgomezch: yeah, they’re two representations of the same abstract thing
[4:31pm] sw17ch: unless the property is "can perform rotation relative to the current position"
[4:31pm] fishcorn: the extra degree of freedom
[4:31pm] sw17ch: where euler angles really can't without resetting the axies
[4:31pm] sw17ch: oh, that's the other thing i'm not sure about
[4:31pm] fishcorn: you're essentially lifting your rotation problem into a manifold one dimension higher
[4:32pm] sw17ch: i j k m
[4:32pm] sw17ch: i think i understand i j and k to be unit vectors
[4:32pm] sw17ch: which give us an orientation in 3d space
[4:32pm] sw17ch: but m? i don't know what m is
[4:32pm] fishcorn: m is the amount of rotation
[4:32pm] mgomezch: how much to rotate!
[4:32pm] vanila: I don't think that's how it works
[4:34pm] milessabin_ joined the chat room.
[4:34pm] fishcorn: it does, it's encoded as the cosine of half the angle in the m coordinate
[4:34pm] fishcorn: http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation http://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions#Quaternions
[4:34pm] welpbot: Title: Quaternions and spatial rotation - Wikipedia, the free encyclopedia, http://tinyurl.com/yuaee9
[4:36pm] cow_2001: omg.
[4:36pm] sw17ch: (i think part of my problem is that i was never taught trig very well and sin cos and tan are buttons on my calculators, not concepts i understand well)
[4:36pm] Ireneista: oh, quaternions.
[4:38pm] sw17ch: fishcorn: in the second link, what does "normalized quaternion" mean?
[4:38pm] fishcorn: sw17ch: well, don't think too hard about cos theta in the quaternion representation, it's just a way to hold the angle
[4:38pm] fishcorn: sw17ch: normalized in the sense that the modulus is 1 I think
[4:38pm] fishcorn: like if you square it it will be 1
[4:39pm] sw17ch: so similar to a unit vector
[4:39pm] fishcorn: like when a rotation matrix has determinant 1
[4:39pm] fishcorn: sw17ch: right
[4:39pm] fishcorn: sw17ch: or when a complex number is restricted to the unit circle
[4:39pm] sw17ch: determinant is a word that means nothing to me
[4:40pm] fishcorn: sw17ch: ok ignore that
[4:40pm] fishcorn: :-)
[4:40pm] sw17ch: "Versors are an algebraic parametrisation of rotations. In classical quaternion theory a versor is a quaternion of norm one (a unit quaternion)."
[4:40pm] sw17ch: it's like learning haskell, but harder
[4:40pm] fishcorn: hah
[4:40pm] cow_2001: sw17ch: everything bad about trigonomy comes from the use of half a unit turn instead of whole unit turn
[4:40pm] cow_2001: trigonometry
[4:40pm] sw17ch: it doesn't help that the links go to broad terms like "algebra"
[4:40pm] sw17ch: and "rotation"
[4:41pm] cow_2001: sw17ch: tauday.com
[4:41pm] fishcorn: sw17ch: true
[4:41pm] mgomezch: cow_2001++
[4:42pm] Apocalisp left the chat room. (Quit: Computer has gone to sleep.)
[4:42pm] fishcorn: sw17ch: I like the Rotation Formalisms article because it gives you nice formulas to convert back and forth between representations
[4:43pm] jle` joined the chat room.
[4:43pm] mgomezch: if you know vector algebra, quaternions are easy to understand as an algebra on a pair of a scalar and a vector
[4:43pm] fronx joined the chat room.
[4:44pm] cow_2001 left the chat room. (Quit: لا إله.)
[4:44pm] mgomezch: then addition and multiplication by a scalar work in the usual way (add two quaternions by adding the two scalars to get the new scalar, and likewise with the vectors, and multiply by a scalar by multiplying both the scalar and the vector by the new scalar)
[4:45pm] fishcorn: mgomezch: that's not how it works with rotations
[4:45pm] mgomezch: and multiplication of two quaternions is the cross product minus the dot product
[4:45pm] mgomezch: no?
[4:45pm] Apocalisp joined the chat room.
[4:46pm] sw17ch: i know linear algebra pretty okay
[4:46pm] fishcorn: sw17ch: note that to apply a quaternion as a rotation, you have to do the "conjugation" operation, described in the http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation article
[4:46pm] welpbot: Title: Quaternions and spatial rotation - Wikipedia, the free encyclopedia, http://tinyurl.com/yuaee9
[4:47pm] sw17ch: so, to bring things back again
[4:47pm] sw17ch: what's actually *is* a vanilla quaternion
[4:47pm] sw17ch: it's a set of 4 numbers
[4:47pm] sw17ch: but i'm not precisely sure how that differs from a 3d vector
[4:47pm] sw17ch: i *think* i know
[4:48pm] fishcorn: so your three d vector is encoded as i j k coefficients
[4:48pm] sw17ch: i think it's that the 3d vector just gives you a *direction*
[4:48pm] sw17ch: not an orientation
[4:48pm] fishcorn: sw17ch: correct
[4:48pm] sw17ch: where direction is what you're facing, and the orientation would be what is considerd "up"
[4:48pm] fronx left the chat room. (Ping timeout: 246 seconds)
[4:48pm] fishcorn: kind of.
[4:48pm] oldskirt_ joined the chat room.
[4:48pm] oldskirt_ left the chat room. (Changing host)
[4:48pm] oldskirt_ joined the chat room.
[4:49pm] sw17ch: up relative to me if i'm the only frame of reference
[4:49pm] sw17ch: heh
[4:49pm] fishcorn: so suppose that your 3d vector points from the center of the earth to Portland
[4:49pm] sw17ch: okay
[4:49pm] fishcorn: and your rotation points through the north pole and has a rotation of 1 hour
[4:49pm] fishcorn: if you apply the rotation to the vector, you've advanced Portland by an hour
[4:50pm] sw17ch: you mean that the rotation would be toward the north pole from portland
[4:50pm] fishcorn: no, it would be in the direction of the earth's rotation
[4:51pm] mgomezch: it’d be parallel to the earth’s axis
[4:51pm] mgomezch: yeah that
[4:51pm] sw17ch: i don't understand how "points through the north pole" implies motion perpendicular to the north pole
[4:51pm] fishcorn: the rotation quaternion encodes *both* the axis *and* the amount of rotation
[4:51pm] sw17ch: wait
[4:51pm] sw17ch: so the axis is center of earth to portland
[4:51pm] fishcorn: that's how rotation works :-)
[4:51pm] fishcorn: sw17ch: no, it's the center of the earth through the north pole
[4:52pm] oldskirt left the chat room. (Ping timeout: 260 seconds)
[4:52pm] sw17ch: the vector
[4:52pm] sw17ch: the vector is pointing at portland
[4:52pm] fishcorn: the axis: center of earth through north pole
[4:52pm] fishcorn: the vector: center of earth through portland
[4:52pm] sw17ch: okay
[4:52pm] NemesisD left the chat room. (Quit: ERC Version 5.3 (IRC client for Emacs))
[4:52pm] sw17ch: so we start with some normal vector, in this case the vector from the center of the earth to the north pole
[4:53pm] sw17ch: then we delcare a vector relative ot this that's our direction
[4:53pm] sw17ch: in this case center of earth to portland
[4:53pm] sw17ch: *THEN* we apply a rotation to that vector ONLY around the normal axis
[4:53pm] sw17ch: yes?
[4:53pm] fishcorn: yes
[4:54pm] sw17ch: okay
[4:54pm] sw17ch: so the quat is [x,y,z, rotation]
[4:54pm] fishcorn: so after you apply it once, it's like the earth turned for 1 hour
[4:54pm] sw17ch: okay
[4:54pm] sw17ch: wait
[4:54pm] mgomezch: yeah, where [x, y, z] as a vector would be parallel to the axis of rotation of the earth
[4:54pm] sw17ch: after applying the rotation once, it turns for an hour
[4:54pm] fishcorn: mgomezch: I got this
[4:54pm] sw17ch: next question
[4:54pm] mgomezch: k sorry (:
[4:55pm] sw17ch: next question
[4:55pm] sw17ch: (thanks mgomezch )
[4:55pm] sw17ch: and thanks fishcorn for htis so far
[4:55pm] sw17ch: this*
[4:55pm] sw17ch: so we have the Vec3 to portland relative to the north pole
[4:56pm] fishcorn: mmm
[4:56pm] sw17ch: how do we define a quat that, when applied? added? whatever? to taht Vec3 to portland
[4:56pm] sw17ch: gets us to berlin
[4:56pm] fishcorn: ah, so that's a little trickier
[4:56pm] sw17ch: so it seems
[4:56pm] fishcorn: basically what you want is this
[4:56pm] sw17ch: but i keep hearing that's why it's helpful
[4:56pm] fishcorn: draw a great circle
[4:56pm] sw17ch: "great circle?"
[4:56pm] fishcorn: between portland and berlin
[4:57pm] sw17ch: a meridian encompasing both?
[4:57pm] sw17ch: or, passing through both?
[4:57pm] fishcorn: great circle path -- the shortest path between two points on the globe
[4:57pm] sw17ch: ah, that's what i was trying to talk about earlier with my "projection of a the arc traveled on a 2d surface" statement
[4:57pm] fishcorn: it probably goes near Iceland :-)
[4:57pm] fishcorn: right, it's a great circle path
[4:58pm] sw17ch: okay got it
[4:58pm] sw17ch: so we define the great circle between berlin and portland
[4:58pm] fishcorn: ok, now that's going to be part of a big circle right?
[4:58pm] fishcorn: (the "great circle")
[4:59pm] sw17ch: what is? our two vectors?
[4:59pm] fishcorn: the path
[4:59pm] sw17ch: oh
[4:59pm] sw17ch: yes
[4:59pm] sw17ch: it's an arc on the circle
[4:59pm] fishcorn: right, so this arc has an associated angle -- record that
[4:59pm] sw17ch: okay
[5:00pm] fishcorn: this circle also has an axis perpendicular to the plane containing it
[5:00pm] milessabin_ left the chat room. (Ping timeout: 255 seconds)
[5:00pm] sw17ch: yes
[5:00pm] fishcorn: that's where the axis direction points (the i,j,k)
[5:00pm] sw17ch: okay, so we do have to reorient things
[5:01pm] sw17ch: and by reorient
[5:01pm] sw17ch: i mean
[5:01pm] fishcorn: if you want a direct path yes
[5:01pm] sw17ch: that's what i was trying to figure out
[5:01pm] fishcorn: you mentioned as the crow flies
[5:01pm] sw17ch: the refrence frame drifts
[5:02pm] fishcorn: the nice thing is that you can pick any cartesian system to do this in, and it still works
[5:02pm] fishcorn: like, you can have (1,0,0) point at Betelgeuse
[5:02pm] sw17ch: okay
[5:03pm] sw17ch: so the order of operations to translate me to berlin from portland
[5:03pm] sw17ch: would be 1)
[5:03pm] sw17ch: well shit
[5:03pm] sw17ch: hah
[5:03pm] sw17ch: wait
[5:03pm] sw17ch: so i think that's where i just need to read about the quats more
[5:03pm] sw17ch: because my assumption is that they are useful particularly because they can encode these sorts of operations
[5:03pm] fishcorn: you can figure this out from the cross product of the vectors trhough portland and berlin
[5:04pm] sw17ch: right, but doesn't that give you something virtually the same as normal linear algebra?
[5:04pm] sw17ch: still trying to figure out why things are different
[5:04pm] fishcorn: the cross product will give you the sine of the angle and the direction of the axis you need, as long as your directions are unit vectors
[5:04pm] fishcorn: sw17ch: yes, but
[5:04pm] fishcorn: normal rotation matrices are a problem because they only do three-dimensional operations
[5:05pm] fishcorn: 3d ops give you gimbal lock
[5:05pm] fishcorn: quaternion ops are 4d
[5:05pm] fishcorn: so you lift yourself out of the space where you have gimbal lock
[5:05pm] sw17ch: 4d, but not in a cartesian way
[5:05pm] sw17ch: right?
[5:05pm] fishcorn: correct
[5:05pm] fishcorn: very important distinction
[5:05pm] sw17ch: ah, okay
[5:05pm] pjdelport: (i just want to briefly pop in and out to say that it would be great if someone can save this discussion later :)
[5:06pm] fishcorn: pjdelport: I will do my best to remember :-)
[5:06pm] sw17ch: three cartiesian coordinates and a 4th coordinate that maps into an immaginary rotational space around the cartesian space
[5:06pm] fishcorn: sw17ch: pretty much
[5:06pm] sw17ch: ah!
[5:06pm] sw17ch: okay
[5:06pm] sw17ch: so now i'm starting to see where the imaginary part comes in
[5:06pm] sw17ch: i'm also not great at imaginary systems
[5:06pm] sw17ch: (i think because multiplication is taught poorly)
[5:07pm] refold left the chat room. (Quit: leaving)
[5:07pm] sw17ch: because multiplication implies two things:
[5:07pm] fishcorn: the way that I think of "imaginary" is as "rotational"
[5:07pm] sw17ch: 1) a direction adn 2) a magnitude
[5:07pm] sw17ch: so breaking all multiplications down to a positive scalar and a "flip" boolean
[5:07pm] fishcorn: that's one way
[5:07pm] sw17ch: gives us the rules for how to multiply negative values
[5:08pm] fishcorn: yeah, that's a good way to think of it
[5:08pm] sw17ch: so squaring a negative value is interesting because we're saying "flip a flipped space by this magnitude"
[5:08pm] fishcorn: yep
[5:08pm] sw17ch: -2 * -2 => the magnitude is 2 * the input magnitude of 2. but the input was in a negative space so we need to flip that as well
[5:09pm] jpfuentes2 joined the chat room.
[5:09pm] sw17ch: the flip and magnitude portions of multiplication are separate
[5:09pm] fishcorn: right
[5:09pm] sw17ch: and realizing that, when we start dealing with squares of negatives
[5:09pm] sw17ch: erm
[5:09pm] sw17ch: roots of negatives
[5:09pm] sw17ch: we see that there's actually two dimensions of "flip we can deal with"
[5:09pm] sw17ch: erm
[5:09pm] sw17ch: "flip" we can deal with
[5:10pm] sw17ch: which, in that system, shows us we can deal with numbers on a two dimensional plane with respect to the flipping operations induced by multiplication on non-positive numberlines
[5:10pm] sw17ch: OKAY SO ANY WAY
[5:10pm] fishcorn: :-D
[5:10pm] sw17ch: bascially, when we talk about "immaginary" what we're saying
[5:11pm] fishcorn: If it helps, this is the way I think about complex numbers:
[5:11pm] fishcorn: complex numbers are a "magnitude" (positive) and a "rotation" about the origin in 2d
[5:12pm] fishcorn: so when you multiply them, you're doing each rotation and multiplying the magnitudes together
[5:13pm] sw17ch: i lost my analogy for the immaginary part
[5:13pm] fishcorn: rather, you're composing the rotations
[5:13pm] fishcorn: that's why the multiplication rules for polar representations multiply the magnitudes and add the angles
[5:14pm] jcaudle_ is now known as jcaudle.
[5:15pm] roboguy_: fishcorn: what do you think of this visualization of complex numbers? http://acko.net/blog/how-to-fold-a-julia-fractal/
[5:15pm] welpbot: Title: How to Fold a Julia Fractal — Acko.net
[5:15pm] sw17ch: okay
[5:16pm] sw17ch: so now i undersatnd quats to be a (Vec3, Angle) pair
[5:16pm] sw17ch: and, if my memory about linear algebra serves me correctly, you could define them as (VecN, Angle)
[5:16pm] fishcorn: sw17ch: unfortunately no
[5:17pm] mgomezch: N = 3 is special (:
[5:17pm] fishcorn: it doesn't generalize to other dimensions
[5:17pm] Rarrikins left the chat room. (Ping timeout: 244 seconds)
[5:17pm] fishcorn: it would be really cool if it did, but it doesn't. :-/
[5:17pm] sw17ch: huh
[5:17pm] sw17ch: that's very unlike mathematics :P
[5:18pm] fishcorn: well you can do it with rotors
[5:18pm] fishcorn: (last entry in that formalisms entry)
[5:18pm] fishcorn: http://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions#Rotors_in_a_geometric_algebra
[5:19pm] welpbot: Title: Rotation formalisms in three dimensions - Wikipedia, the free encyclopedia, http://tinyurl.com/coqwkkk
[5:19pm] Rarrikins joined the chat room.
[5:19pm] fishcorn: because you can rotate in higher than 3 dimensions but it gets weird
[5:19pm] sw17ch: fishcorn: heh. i think things are weird in higher dimensions only becase we can't properly visualize what's going on
[5:19pm] fishcorn: sw17ch: true
[5:19pm] sw17ch: unfamiliar might be a better term than weird
[5:20pm] sw17ch: which i suppose
[5:20pm] sw17ch: they are the same word
[5:20pm] fishcorn: :-)
[5:20pm] sw17ch: or synonyms
[5:20pm] fishcorn: well I don't mean to be three-dee-ist :-)
[5:20pm] mgomezch: some of my physicist friends believe there’s a connection between this particular way in which 3 dimensions is special, and the fact that our space has 3 spatial dimensions
[5:20pm] fishcorn: mgomezch: I wonder that myself sometimes
[5:21pm] fishcorn: because 3d is *so unique*
[5:21pm] mgomezch: indeed, it’s all nice and elegant and regular in too many ways
[5:21pm] sw17ch: i never finished my order of operations thing
[5:21pm] sw17ch: to quickly rephrase
[5:21pm] sw17ch: a quat gives me a position in 3d space relative to a normal vector
[5:21pm] sw17ch: to use a quat as a rotation on a vector
[5:22pm] sw17ch: or, sorry
[5:22pm] sw17ch: to derive a quat from two vectors
[5:22pm] sw17ch: we use a normal perpendicular to the great circle intersecting both vectors
[5:22pm] jpfuentes2 left the chat room. (Ping timeout: 243 seconds)
[5:22pm] sw17ch: and calculate the angle between the vectors
[5:23pm] sw17ch: this gives us a rotation that, when applied to the first would give us the second
[5:23pm] fishcorn: right (which you can do by looking at the cross product)
[5:23pm] sw17ch: but oddly, when applied to the second, would not give us the first
[5:23pm] fishcorn: but!
[5:23pm] sw17ch: but it's inverse would...
[5:23pm] sw17ch: hmmm
[5:23pm] fishcorn: when you apply the negative of it to the second you get the first
[5:23pm] sw17ch: negative being you change the direction of the normal vector, right?
[5:23pm] fishcorn: right
[5:23pm] sw17ch: \o/
[5:23pm] sw17ch: i'm learning!
[5:24pm] fishcorn: :-D
[5:24pm] jpfuentes2 joined the chat room.
[5:24pm] sw17ch: okay
[5:24pm] sw17ch: so here's the other weird part
[5:24pm] sw17ch: well maybe not
[5:24pm] sw17ch: so say we're going to berlin, then bejing, then austin
[5:24pm] sw17ch: so
[5:24pm] sw17ch: portland -> berlin -> bejing -> austin
[5:25pm] Rarrikins left the chat room. (Ping timeout: 246 seconds)
[5:25pm] sw17ch: this travel plan can be encoded as the porland vector and 3 quats
[5:25pm] fishcorn: yes
[5:25pm] sw17ch: but would applying the three quats in a random order still get us to austin?
[5:25pm] hashem joined the chat room.
[5:25pm] fishcorn: not in a different order
[5:25pm] fishcorn: non-commutative operation
[5:25pm] sw17ch: okay, i need to work out why in my head quick
[5:26pm] sw17ch: i was just makign sure i understood that property
[5:26pm] fishcorn: pick up an (empty) coffee cup and turn it 90 degrees twice, on different axes
[5:26pm] fishcorn: then reverse the order
[5:27pm] sw17ch: why must it be empty??!? ;)
[5:27pm] fishcorn: well it doesn't have to be... :-P
[5:27pm] sw17ch: ooooooo that's a really good example
[5:28pm] fishcorn: however
[5:28pm] sw17ch: okay awesome
[5:28pm] sw17ch: so that's strange
[5:28pm] fishcorn: the operation *is* associative
[5:28pm] sw17ch: because adding vectors in 2d
[5:28pm] sw17ch: oh hey
[5:28pm] fishcorn: so you can just do them all together and you go straight from portland to austin
[5:28pm] sw17ch: just adding vectors in normal cartesian space is still commutative
[5:29pm] sw17ch: fishcorn: okay THAT is cool
[5:29pm] sw17ch: so you musn't perform them all at once
[5:29pm] sw17ch: i mean
[5:29pm] sw17ch: individually
[5:29pm] sw17ch: to get the final result
[5:29pm] sw17ch: so i can compose the quats
[5:29pm] sw17ch: and apply them at once
[5:29pm] fishcorn: yep
[5:29pm] fishcorn: which would be more efficient
[5:29pm] mgomezch: compositional rotation!
[5:29pm] sw17ch: am i right about the cartesian spaces/
[5:29pm] sw17ch: ?*
[5:29pm] welpbot: Maybe you meant: v @ ? .
[5:29pm] fishcorn: because composition is cheaper than application
[5:29pm] fishcorn: sw17ch: yeah, because it's addition
[5:30pm] sw17ch: fishcorn: just making sure
[5:30pm] sw17ch: thanks
[5:30pm] sw17ch: okay so, in short
[5:30pm] sw17ch: quats 1) don't have the gimbal lock problem because they have an extra degree of freedom
[5:30pm] sw17ch: 2) are compositional
[5:30pm] sw17ch: 3) are NOT commutative
[5:30pm] fishcorn: yes, yes, and yes
[5:30pm] sw17ch: compositional/associative
[5:31pm] sw17ch: fishcorn: okay, so reaching WAY back in time here
[5:31pm] fishcorn: for associativity think Monoids
[5:31pm] sw17ch: (like, minutes ago even)
[5:31pm] sw17ch: in that video with the farmer and the gimbal lock on the arm
[5:31pm] RchrdB: so quats form a monoid?
[5:31pm] sw17ch: could quats have been used in that case to avoid the problem entirely?
[5:31pm] fishcorn: RchrdB: yes
[5:32pm] fishcorn: sw17ch: yes, but axes and angles are really easy to intuit
[5:32pm] fishcorn: quats are a little harder
[5:32pm] sw17ch: fishcorn: but it's not an underlying limitation in the computer
[5:32pm] sw17ch: it's a limitation in the computational model?
[5:32pm] fishcorn: sw17ch: not at all
[5:32pm] fishcorn: right
[5:32pm] sw17ch: okay!
[5:32pm] sw17ch: awesome
[5:32pm] roboguy_: RchrdB: they almost form a field iirc
[5:32pm] sw17ch: so one picks a rotational algebra
[5:33pm] sw17ch: and euler angles are pretty easy to undrestand, but have this odd corner case where two axies line up
[5:33pm] roboguy_: the commutativity is the one thing that's missing for that I think
[5:33pm] fishcorn: roboguy_: it's a field sans commutativity
[5:33pm] fishcorn: roboguy_: "non-commutative division ring"
[5:34pm] sw17ch: a rotational algebra/grammar/language centered around quaternions loses commutativity, but doesn't have the gimbal lock
[5:34pm] RchrdB: "almost form a field except that multiplication doesn't commute" is what the wikipedia article refers to as "first non-commutative division ring to be discovered"?
[5:34pm] fishcorn: RchrdB: yep!
[5:34pm] jpfuentes2 left the chat room. (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
[5:34pm] RchrdB: ta
[5:34pm] sw17ch: does any one mind if i toss all this in a gist?
[5:34pm] fishcorn: sw17ch: another way to look at that farmer example is that the designer added a degree of freedom to compensate
[5:34pm] RchrdB: I have a vague memory of some course in uni showing me how to arithmetic on quats once but I then forgot it.
[5:35pm] fishcorn: in fact, all those examples do that
[5:35pm] fishcorn: sw17ch: I certainly don't, in fact, I think pjdelport wanted a transcript anyway
[5:35pm] sw17ch: i'm trying to figure out if i have all the scrollback now...
[5:36pm] fishcorn: I do if you don't
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment