rot * rot Wierdness
|
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
|
10-13-2004 03:24
made a drawbridge today and in doing so noticed some odd behaviour when multiplying a rotation by another rotation (applying a rotation relative to the objects current rotation). 5 * 3 = 3 * 5 Everyone agree? ah, but not with rotations, which probably makes sense to someone, but not me  . llGetRot() * new_rot != new_rot * llGetRot(); Incidentally, to rotate the bridge to the up position relative to it's starting position, new_rot * llGetRot() was the one I wanted.
|
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
|
10-13-2004 04:07
The wiki is your friend, and has a good discussion on combining rotations here. You are correct... The "*" operator, when used with rotation operands, is NOT commutative. Basically, one way applies the desired rotation around the object's local axis, while the other applies it around the global. Don't worry. I have a B.Sc. in Mathematics, and rotations give ME headaches too. - Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
|
Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
|
10-13-2004 07:23
It's actually logical: a rotation represents a rotation.
Take a book, put it on your desk.
Rotate it about the rooms x-axis by 90 degrees Now rotate it about the rooms z-axis by 90 degrees
Take another book, put it on your desk, repeat but the other way around: Rotate it about the rooms z-axis by 90 degrees Now rotate it about the rooms x-axis by 90 degrees
They're in diffferent rotations now right? Even though the rotations applied were the exact same rotations.
Azelda
|
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
|
10-13-2004 09:08
From: Azelda Garcia It's actually logical: a rotation represents a rotation.
Take a book, put it on your desk.
Rotate it about the rooms x-axis by 90 degrees Now rotate it about the rooms z-axis by 90 degrees
Take another book, put it on your desk, repeat but the other way around: Rotate it about the rooms z-axis by 90 degrees Now rotate it about the rooms x-axis by 90 degrees
They're in diffferent rotations now right? Even though the rotations applied were the exact same rotations.
Azelda Actually, that is the reason for using quaternions, as opposed to Euler rotations. Euler rotations (which is the number of degrees around each axis) is highly dependent on the order in which those individual rotations are applied. The order of operands when using the "*" operator on rotations is, as I said in my previous post", simply a matter of saying whether the rotation to be applied to an object with another rotation is whether it is in local coordinates, or global. - Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
|
Francis Chung
This sentence no verb.
Join date: 22 Sep 2003
Posts: 918
|
10-13-2004 15:39
Hi Ace,
Not entirely sure what you're talking about Ace. Euler is just a way of expressing a rotation, just like a quaternion. However, to combine two rotations expressed as Euler's, it's easiest to convert to another form (such as quaternions), and then convert it back. So you might as well just store things in quaternions, and not have to convert it at all.
But to try to remove the confusion, it helps to think of rotations as matrices, if you're familiar with that domain.
They're associative ( (a*b)*c = a*(b*c) ) but not commutative ( a*b = b*a ).
Like Az said, the order in which you apply your transformations is important.
_____________________
-- ~If you lived here, you would be home by now~
|
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
|
10-13-2004 17:35
From: Francis Chung Hi Ace,
Not entirely sure what you're talking about Ace. Euler is just a way of expressing a rotation, just like a quaternion. However, to combine two rotations expressed as Euler's, it's easiest to convert to another form (such as quaternions), and then convert it back. So you might as well just store things in quaternions, and not have to convert it at all.
But to try to remove the confusion, it helps to think of rotations as matrices, if you're familiar with that domain.
They're associative ( (a*b)*c = a*(b*c) ) but not commutative ( a*b = b*a ).
Like Az said, the order in which you apply your transformations is important. Alright... You asked for the math geek in me, you got it. I hope I get this right... I'm not a 3D programming whiz, but its my understanding that quaternions are preferable to Euler for representing rotations is because an Euler representation of a rotation is not invertible. I'll try my best here to use the "visualation" I once read (I wish I could find the site, because it made it clear the deficiency in Euler repesentation) that used the example of a paper airplane to demonstrate the problem with using Euler. Take a paper airplane, and orient it so that the top is facing you, and the nose point up. And we'll mark the axes, so that you are looking along the X-axis, the Y-axis runs left to right, and the Z-axis down to up. I'll use degrees instead of radians, since most people think in degrees. If you want to rotate this airplane from its original position 90 degrees along each axis, rotating around X first, then Y, and then Z, you'll end up with the plane "upside down, and with its nose pointed away from you. But if you rotate it -90 degrees along each axis, but go in the order Y, X, Z, then the plane will NOT be in the same position it started in. What this ends up saying is that the 3 values in an Euler representation are not sufficient to fully represent a rotation. And it can be shown mathematically that always insisting on the same order (say X, Y, Z) doesn't ensure that inverting a set of operations will ALWAYS result in you coming back to where you started. Eulers are simply insufficient to fully represent a rotation. Three degrees of freedom doesn't cut it. What's really needed is a rotation matrix (which would be 9 values in a 3x3 matrix), but it also can be show mathematically that, because of redundancy in this matrix, only 4 values are actually required. And thus the quaternion is used to represent this rotation matrix. But back to my original point in the earlier post... The order of the operands defines how you apply a rotation. Suppose you have an object, and its current rotation is 'a', and you want to rotate it by rotation 'b'. You'd calculate the new rotation 'c' by either : rotation c = a * b // rotates around the 'global' axes -or- rotation c = b * a // rotates around the object's 'local' axes That's the difference between the order of operands, and it has nothing to do with Eulers. Its just quaternions are better at representing rotations than Eulers, and this is the meaning of quarternion arithmetic. Hope this helps... - Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
10-14-2004 11:30
Now to complicate the issue, quaternions have another advantage over eulers: no gimble lock. gimble lock is the phenomenon that happens when one axis overlaps another. Example the y axis angle is set to 90 degrees (the z axis overlaps the x axis). I'm having trouble describing this ~_~ anyway gimble lock is bad. when a gimble is locked it's difficult to move to out of the lock in any direction that isn't along the axis that you entered the lock with. (that is without moving the other gimbles first). But quaternions don't suffer from gimble lock because they don't work the same way. How they work is beyond me. Resulting in the ability to be able to use/make SLERP (Spherical Linear Interpolation) without going insane. http://www.gamedev.net/reference/articles/article1095.asphttp://mathworld.wolfram.com/Quaternion.htmlhttp://www.delphi3d.net/articles/viewarticle.php?article=quaternions.htmhttp://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
Francis Chung
This sentence no verb.
Join date: 22 Sep 2003
Posts: 918
|
10-14-2004 12:20
From: Ace Cassidy Al I'm not a 3D programming whiz, but its my understanding that quaternions are preferable to Euler for representing rotations is because an Euler representation of a rotation is not invertible.
Rotations are invertible. The fact that you represent them with an Euler is irrelevant. To emphasize my point I'm going to say it more bluntly: Euler representations of a rotation are invertible. From: someone I'll try my best here to use the "visualation" I once read (I wish I could find the site, because it made it clear the deficiency in Euler repesentation) that used the example of a paper airplane to demonstrate the problem with using Euler. ...
You can't follow this example, because you haven't defined your coordinate system. (Which way is +ve? Are you observing a right/left hand rule, etc) From: someone What this ends up saying is that the 3 values in an Euler representation are not sufficient to fully represent a rotation. And it can be shown mathematically that always insisting on the same order (say X, Y, Z) doesn't ensure that inverting a set of operations will ALWAYS result in you coming back to where you started. Eulers are simply insufficient to fully represent a rotation. Three degrees of freedom doesn't cut it.
You can't show it mathematically, because it's not true. Euler's are completely sufficient in representing a rotation. 3 values are enough. Quaternions actually have "too much" freedom, since they offer 4 dimensions of freedom. We "take away" one direction of freedom by insisting that quaternions that express rotations are normalized. I'm not sure what the easiest way to convince you of this, but you seem pretty sharp. I think it will come to you if you think about it for a while. llRot2Euler() only returns 1 value for a reason  From: someone What's really needed is a rotation matrix (which would be 9 values in a 3x3 matrix), but it also can be show mathematically that, because of redundancy in this matrix, only 4 values are actually required. And thus the quaternion is used to represent this rotation matrix.
The use of a matrix is not really necessary, and not necessarily invertible. 3x3 matrices can also be used to represent transformations such as stretching and scaling. In computer graphics, they often like to use 4x4 matrices, so that translations can also be expressed as part of a transformation. But here's why we don't use matrices when we want to represent rotations: - Floating point arithmetic isn't precise. The numbers float around a bit. So, after a few operations, it's easy to end up with a matrix that no long represents a rotation. A matrix represents a rotation iff it's orthogonal, with a determinant of 1. That's unpleasant to try and enforce. We don't like Euler's, because it's not easy to compose two Euler's. It's easier convert it into an intermediate form (such as quaternions) and then convert it back. This is inelegant and inefficient. We like quaternions, because they've only got 1 degree of unecessary freedom. To make sure a quaternion is a valid rotation, you just need to normalize it. From: someone That's the difference between the order of operands, and it has nothing to do with Eulers. Its just quaternions are better at representing rotations than Eulers, and this is the meaning of quarternion arithmetic.
This part is correct. Rotations are inherently not commutative, whether your reprent them as Eulers, quaternions, or matrices.
_____________________
-- ~If you lived here, you would be home by now~
|
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
|
10-14-2004 13:04
From: Francis Chung Rotations are invertible. The fact that you represent them with an Euler is irrelevant. To emphasize my point I'm going to say it more bluntly: Euler representations of a rotation are invertible. And I'll reiterate... Euler rotations are dependent on the order of the application of rotation around each of the three axes. The web-page I refered to earlier, that shows the deficiency of Euler representation, by way of a rotating airplane example, is here From: Francis Chung You can't follow this example, because you haven't defined your coordinate system. (Which way is +ve? Are you observing a right/left hand rule, etc) Well... I did quite explicitly define the 3 axes, and I guess I just assumed right-hand rule, since that is what SL uses. But it doesn't really matter whether it was left-hand or right-hand, because the problem is the same in either case. From: Francis Chung The use of a matrix is not really necessary, and not necessarily invertible. 3x3 matrices can also be used to represent transformations such as stretching and scaling. Of course there are singular 3x3 matrices, and of course many 3x3 transformations scale the axes. That's beside the point. But every 3x3 matrix that maps a unit vector onto another point on the unit sphere (which is exactly what a rotation is) is invertible, and can be represented with a quaternion (i.e. 4 degrees of freedom). But we've run ourselves down the rat-hole of the Euler/quaternion debate, when all that was asked was why rotation arithmetic is not commutative. And the info I offered about what the difference between a*b and b*a is still valid. One order of operands rotates around the global axes, while the other order rotates around the local. - Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
|
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
|
10-14-2004 13:10
Oh yeah... And Strife is right, and was actually agreeing with what I was stating. The deficiency of Euler representation is known as Gimbal lock.
- Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
|
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
|
10-14-2004 13:21
Now I may be a simple hyper chicken, but it seems to me that Eulers and Quanterions are *representations* of rotations, and while it happens that quanterions are easier to work with internally and are the default rotation type, any Euler can be transformed to a Quanterion, and any (valid) Quanterion can be transformed to a Euler.
You're arguing about which is further, 1 mile or 1.609 kilometers.
_____________________
Sarcasm meter: 0 |-----------------------*-| 10 Rating: Awww Jeeze!
|
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
|
10-14-2004 13:34
From: Wednesday Grimm Now I may be a simple hyper chicken, but it seems to me that Eulers and Quanterions are *representations* of rotations, and while it happens that quanterions are easier to work with internally and are the default rotation type, any Euler can be transformed to a Quanterion, and any (valid) Quanterion can be transformed to a Euler.
You're arguing about which is further, 1 mile or 1.609 kilometers. Hehe... I'm not sure how I got into the kafuffle, since I'm really not a zealot for either side of the issue. I was just trying to explain my limited understanding of the problem. Your quote should read "any Euler can be transformed to an infinite number of unique quaternions..."... Its not a one-to-one transformation. - Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
|
Francis Chung
This sentence no verb.
Join date: 22 Sep 2003
Posts: 918
|
10-14-2004 14:14
Aha! Okay Ace, I've figured it out. We've been kind of talking past each other. We're saying the same thing in different ways. I can do a play-by-play analysis of where the communication breakdown happened, but we're in agreement about everything except: From: Ace Cassidy What this ends up saying is that the 3 values in an Euler representation are not sufficient to fully represent a rotation.
because every rotation can be represented by an Euler. You just don't want to compose your rotations in Euler-space. (That's that conversion step I was talking about, which avoids the "Gimbal's Lock" problem, because compositions of rotations aren't naively constructed by doing a sum of euler-coordinates)
_____________________
-- ~If you lived here, you would be home by now~
|
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
|
10-14-2004 16:09
uh huh ::nods::. actually I did understand most of that. If I'd have thought about it for half a second I'd have realized that of course rotation * rotation wouldn't be commutative. Just out of curiousity is the * opperator always defined this way in relation to quaternions? Always bugs me when notation has different rules depending on the variable units :/. Seems... imprecise, ambiguous... something. Thanks for all the feedback btw  .
|
Jake Cellardoor
CHM builder
Join date: 27 Mar 2003
Posts: 528
|
10-14-2004 17:26
From: Wednesday Grimm Now I may be a simple hyper chicken LOL. Ah, gotta love the judicial system in Futurama. From: Rickard Roentgen Just out of curiousity is the * opperator always defined this way in relation to quaternions? Always bugs me when notation has different rules depending on the variable units :/. Seems... imprecise, ambiguous... something. In LSL, yes, the * operator behaves differently depending on the types of the operands. It can be confusing at times. (For example, when dealing with rotations, the / operator multiplies the first operand by the inverse of the second operand, but don't think of it as division.)
|
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
|
10-14-2004 18:22
actually I mean in mathematical circles  . You know those crazy people who actually got a degree in this stuff. In RL is what I would consider quaternion addition represented by multiplication notation?
|
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
|
10-14-2004 18:24
From: Jake Cellardoor the / operator multiplies the first operand by the inverse of the second operand, but don't think of it as division.) actually, I did not know this. I've been inverting the second and then multiplying. this will save me a few lines of code.
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
10-14-2004 21:19
From: Rickard Roentgen actually, I did not know this. I've been inverting the second and then multiplying. this will save me a few lines of code. i only found out about it when looking for code samples to write functions for converting between eulers <-> quaternions. The easy way of inverting a quaternion is just <0,0,0,1>/rot personaly i would like to see more quaternion handling functions. Including a function to normalize them.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
Francis Chung
This sentence no verb.
Join date: 22 Sep 2003
Posts: 918
|
10-15-2004 09:39
From: Rickard Roentgen Just out of curiousity is the * opperator always defined this way in relation to quaternions? Always bugs me when notation has different rules depending on the variable units :/. Seems... imprecise, ambiguous... something.
The definition of Quaternions is really wonky. It's like an extension to complex numbers, with an i, j and k, all of which are the square root of -1. So you get numbers of the form 1 + 2i + 3j + 4k. Here's the screwy thing: i * j = k, but j * i = -k. (of course i*i = j*j = k*k = -1) You can add and multiply quaternions same as polynomails  (Look into group/ring theory for a more info on these kinds of systems) I never figured out why Quaternions were invented in the first place. As far as I can tell, they don't solve any problem in mathematics - in the end, they just turned out to be handy for some applications in Computer Graphics 
_____________________
-- ~If you lived here, you would be home by now~
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
10-15-2004 11:59
I believe the application to storing rotations in quaternion form happened when a Scotsman walking along the themes in london decided to take a knife and scratch a clever idea into the themes bounding wall. (thats the gist of the story at least, i'm told you can still see his carvings to this day) Quaternions i've read aren't used for much else.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
Jake Cellardoor
CHM builder
Join date: 27 Mar 2003
Posts: 528
|
10-15-2004 12:27
From: Rickard Roentgen In RL is what I would consider quaternion addition represented by multiplication notation? Well, what is multiplication notation in RL?  People sometimes write "2 × 3" when dealing with explicit numbers, but sometimes they write "2 · 3" instead. They usually don't use an operator symbol at all when dealing with variables ("3a" rather than "3 · a"  . When it comes to vectors, folks often use boldface to distinguish vectors from scalar variables, and there are both dot products (" i • j"  and cross products (" i × j"  . And we're just getting started. There actually is an operation known as quaternion addition that is different from quaternion multiplication. The operation we've been discussing in this thread is quaternion multiplication, and is often represented as "pq", for what it's worth. From: Francis Chung I never figured out why Quaternions were invented in the first place. As far as I can tell, they don't solve any problem in mathematics - in the end, they just turned out to be handy for some applications in Computer Graphics  Supposedly Hamilton invented them because he was wondering if there was a three-dimensional equivalent to complex numbers. There isn't, but in four dimensions you get quaternions. And apparently they are used for representing rotations in actual orbital mechanics calculations.
|