## Re: [Algorithms] Re: Quaternion handedness

 Re: [Algorithms] Re: Quaternion handedness From: Thatcher Ulrich - 2002-11-27 21:26:00 ```> > So why can't we just adopt math's convention of using > > predominantly right-handed operations and live saner lives where > > we never have to have a thread like this again? The least significant byte should have the lowest address! -- Thatcher Ulrich http://tulrich.com ```

 RE: [Algorithms] Quaternion handedness From: Joseph, William - 2002-11-22 17:55:24 ```If I understand matrix stuff correctly, a rotation-only matrix is always right-handed - even when working in a left-handed coordinate system. If your rotation matrix is left-handed, transforming a space by it will cause that space to switch handedness. For example.. object space A is left-handed and object->world rotation matrix B is left-handed. Applying B to A will result in the object appearing right-handed in world-space... I think. To construct the rotation matrix correctly, you have to do it in the correct space. I'm not familiar with tangent-space transforms.. but you may be able to do this by converting the left-handed basis to right-handed, extracting the rotation, then converting back to left-handed. I suggest experimenting.. -Will -----Original Message----- From: Joe Ante [mailto:joeante@...] Sent: 22 November 2002 16:23 To: gdalgorithms-list@... Subject: [Algorithms] Quaternion handedness Hi, I am trying to convert tangent space 3x3 matrices for dot3 product bumpmapping to quaternions. I want to convert these 3x3 matrices into quaternions to do the objectspace- tangentspace transformation, because I need to slerp my tangentspace transform when doing geomorphing on my chunk lod mesh. The tangentspace orthonormal bases are sometimes right handed, sometimes left handed. Unfortunately my matrix to quaternion algorithm seems not to work on left handed matrices. (I am using the algorithm availible at magic-software) Is there any way to represent a left-handed matrix as a quaternion? What do I have to do to convert my left-handed orthonormal matrix into a quaternion? Joe Ante ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ GDAlgorithms-list mailing list GDAlgorithms-list@... https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=6188 ```
 RE: [Algorithms] Quaternion handedness From: Michael Pohoreski - 2002-11-22 19:20:39 Attachments: Message as HTML ```Be aware that different books will use or not use a transposed quat->matrix. i.e. "3D Game Engine Design", Page 17, Section 2.3.5, Eqn 2.13 and "Rotating Objects Using Quaterions" (Corrected matrix) Game Developer, Feb 98, Nick Bobick RHCS? 2 2 =20 [ 1 - 2y - 2z 2xy + 2wz 2xz - 2wy ] [ 2 2 ] [ 2xy - 2wz 1 - 2x - 2z 2yz + 2wx ] [ 2 2 ] [ 2xz + 2wy 2yz - 2wx 1 - 2x - 2y ] Used by Watt&Watt, Parameetrization of orientation, Page 362 LHCS? 2 2 =20 [ 1 - 2y - 2z 2xy - 2wz 2xz + 2wy ] [ 2 2 ] [ 2xy + 2wz 1 - 2x - 2z 2yz - 2wx ] [ 2 2 ] [ 2xz - 2wy 2yz + 2wx 1 - 2x - 2y ] Cheers -----Original Message----- From: Tyson Jensen [mailto:twjensen@...]=20 Sent: Friday, November 22, 2002 1:41 PM To: gdalgorithms-list@... Subject: RE: [Algorithms] Quaternion handedness Huh? We wrote an entire game in left-handed coordinates and we never noticed any "magic" preference for right-handedness in matrices. I am unclear as to why arithmetic would care what hand humans tend to prefer. What happens is that care must be taken when copying algorithms out of books that might be making handed-ness assumptions. I'd bet money that lhA * lhB =3D right handed space is a result of a bias in code, not in = the math. If you have a left-handed world and use left-handed transforms your stuff will remain left-handed. I recommend a constant matrix that can be applied to convert a matrix from left-handed to right-handed and another one that goes in reverse. I'd recommend doing all your quaternion stuff in (pick a hand) space. If a matrix is (other-handed) then convert the matrix to the (correct-handed) space, convert to quaternion, do whatever, convert back, and then convert the (correct-handed) matrix back into an (other-handed) matrix. Trying to maintain left-handed quaternions and right-handed quaternions is just compounding the problem of having both left-handed coordinate spaces and right handed coordinate spaces. -----Original Message----- From: gdalgorithms-list-admin@... [mailto:gdalgorithms-list-admin@...] On Behalf Of Joseph, William Sent: Friday, November 22, 2002 9:55 AM To: 'gdalgorithms-list@...' Subject: RE: [Algorithms] Quaternion handedness If I understand matrix stuff correctly, a rotation-only matrix is always right-handed - even when working in a left-handed coordinate system. If your rotation matrix is left-handed, transforming a space by it will cause that space to switch handedness. For example.. object space A is left-handed and object->world rotation matrix B is left-handed. Applying B to A will result in the object appearing right-handed in world-space... I think. To construct the rotation matrix correctly, you have to do it in the correct space. I'm not familiar with tangent-space transforms.. but you may be able to do this by converting the left-handed basis to right-handed, extracting the rotation, then converting back to left-handed. I suggest experimenting.. -Will -----Original Message----- From: Joe Ante [mailto:joeante@...] Sent: 22 November 2002 16:23 To: gdalgorithms-list@... Subject: [Algorithms] Quaternion handedness Hi, I am trying to convert tangent space 3x3 matrices for dot3 product bumpmapping to quaternions. I want to convert these 3x3 matrices into quaternions to do the objectspace- tangentspace transformation, because I need to slerp my tangentspace transform when doing geomorphing on my chunk lod mesh. The tangentspace orthonormal bases are sometimes right handed, sometimes left handed. Unfortunately my matrix to quaternion algorithm seems not to work on left handed matrices. (I am using the algorithm availible at magic-software) Is there any way to represent a left-handed matrix as a quaternion? What do I have to do to convert my left-handed orthonormal matrix into a quaternion? Joe Ante ```
 RE: [Algorithms] Quaternion handedness From: Nick Pelling - 2002-11-26 10:51:52 ```A unit quaternion is no more and no less than than a rotation around an axis - handedness (relative to the coordinate frame) is explicit, because the signs of each of the sine and cosine components are included in the quaternion. Also: in normal rotation matrices, the resulting matrix is composited out of a sequences of rotation matrices, and is both order-sensitive and handedness-sensitive. However, for a rotation angle 3-tuple, the handedness is implicit, as are its axis association and order. So: when linking between rotation angle 3-tuples and quaternions, you need to get all the implicit stuff right, or you'll get a load of nonsense. Unsurprisingly, "This Often Happens". :-/ I could put a load of quaternion maths in here to demonstrate this basic point, but it really shouldn't be necessary. :-) Cheers, .....Nick Pelling..... -----Original Message----- From: Peter Lipson [mailto:peter@...] Sent: 25 November 2002 18:16 To: gdalgorithms-list@... Subject: RE: [Algorithms] Quaternion handedness This whole discussion seems to be lacking any answer based on the theoretical basis for using quaternions to hold the rotations. I know quaternions used for rotation are constructed by using the axis and sin/cos of the angle, but I have a less firm grasp of the theoretical underpinnings that guarantee this 'works'. I'd love to see Ron's (or some other mathematician's) explanation of how handedness is incorporated into this representation. I have my own explanation, but I'm -not- a mathematician myself! ```
 RE: [Algorithms] Quaternion handedness From: Tyson Jensen - 2002-11-26 17:44:19 ```Actually, technically a quaternion multiply (unit or otherwise) represents a screw transform. The typical way quaternions are applied, ie qvq* where q is a unit quaternion, insures that the translational element is removed leaving a pure rotation. Since we game programmers haven't really gotten into screw theory, all of our quaternions represent rotations. As with many mathematical constructions, our plans for how we are going to use them make a big difference in what they represent. For example, a matrix can do all kinds of things besides rotate and translate but the only thing we typically do outside of those is a perspective transform. -----Original Message----- From: gdalgorithms-list-admin@... [mailto:gdalgorithms-list-admin@...] On Behalf Of Nick Pelling Sent: Tuesday, November 26, 2002 2:52 AM To: 'gdalgorithms-list@...' Subject: RE: [Algorithms] Quaternion handedness A unit quaternion is no more and no less than than a rotation around an axis - handedness (relative to the coordinate frame) is explicit, because the signs of each of the sine and cosine components are included in the quaternion. Also: in normal rotation matrices, the resulting matrix is composited out of a sequences of rotation matrices, and is both order-sensitive and handedness-sensitive. However, for a rotation angle 3-tuple, the handedness is implicit, as are its axis association and order. So: when linking between rotation angle 3-tuples and quaternions, you need to get all the implicit stuff right, or you'll get a load of nonsense. Unsurprisingly, "This Often Happens". :-/ I could put a load of quaternion maths in here to demonstrate this basic point, but it really shouldn't be necessary. :-) Cheers, .....Nick Pelling..... -----Original Message----- From: Peter Lipson [mailto:peter@...] Sent: 25 November 2002 18:16 To: gdalgorithms-list@... Subject: RE: [Algorithms] Quaternion handedness This whole discussion seems to be lacking any answer based on the theoretical basis for using quaternions to hold the rotations. I know quaternions used for rotation are constructed by using the axis and sin/cos of the angle, but I have a less firm grasp of the theoretical underpinnings that guarantee this 'works'. I'd love to see Ron's (or some other mathematician's) explanation of how handedness is incorporated into this representation. I have my own explanation, but I'm -not- a mathematician myself! ------------------------------------------------------- This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size! http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en _______________________________________________ GDAlgorithms-list mailing list GDAlgorithms-list@... https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=6188 ```
 [Algorithms] Re: Quaternion handedness From: Casey Muratori - 2002-11-26 22:00:41 ```> A unit quaternion is no more and no less than than a rotation around an > axis - handedness (relative to the coordinate frame) is explicit, > because the signs of each of the sine and cosine components are included > in the quaternion. OK I think this thread is starting to get out of control, so here we go: Quaternions have no handedness. I'm not sure how the initial concept that a quaternion has a handedness got started, but to quote Marsellus Wallace, "it don't". Just like vectors, there is only a handedness to your _operations_. You wouldn't call your vectors left-handed or right-handed, would you? But you _would_ (or I certainly hope you would!) call your cross-product left-handed or right-handed, correct? The same situation applies to quaternions. When you wrote your quaternion multiply, you used a cross product (or, as is apparently more likely, if you cut and pasted somebody else's code, THEY used a cross product). If your/their cross product is right-handed, then your/their quaternions are going to multiply right-handed. If it's left, they'll multiply left. It's really that simple. Or, if you prefer, "it's really that complicated". And so forth. Now as for this this: > I'd love to see Ron's (or some other mathematician's) explanation of how > handedness is incorporated into this representation. I have my own > explanation, but I'm -not- a mathematician myself! Thankfully, the explanation is simple and doesn't require a mathematician. As everyone has seen many times, quaternion operations are all defined by setting up multiplication rules for the imaginary components i, j, and k. Well, if you had been ignoring those derivations previously, now's your chance to stop ignoring them. Go back and look, and you'll see that the "handedness" is baked into those initial definitions. If you change the initial multiplication rules to be left-handed, then all the operations will come out left-handed. Right handed systems have: i^2 = j^2 = k^2 = ijk = -1 i = jk = -kj j = ki = -ik k = ij = -ji and left handed systems have: i^2 = j^2 = k^2 = -ijk = -1 i = -jk = kj j = -ki = ik k = -ij = ji And that's all there is to it. k is the "z-axis". If you want to invert your z axis, you just define the fact that i (x-axis) and j (y-axis) multiply together to get negative k. Obviously, you don't have to restrict yourself to making k negative, you could've negated something else instead. For some reason, Shoemake never presented the left-handed version (as far as I'm aware), so I guess nobody ever thought about it? Not sure. Anyhow, go ahead and do the quaternion multiplication (w + xi + yj + zk) (d + ai + bj + ck) with each rule set and see what you get. You'll find that you get a right-handed cross product when you use the right-handed rules, and a left- handed cross product when you use the left-handed rules, and otherwise the two will be identical. Now I would simply like to say hey, if I had to hazard a guess as to why everyone thinks quaternions are inherently right-handed, and the left-handed definition doesn't ever show up, I'd say it's because that's the way most math is written by default: right-handed. So when you go and read something in a math book, it's probably right-handed. So why do some people still insist on using these left-handed coordinate frames? For the love of god, people, stop using left-handed coordinate systems so we can put an end to all this useless conversion confusion. There's no advantage to one or the other - they're the same in every way. So why can't we just adopt math's convention of using predominantly right-handed operations and live saner lives where we never have to have a thread like this again? - Casey ```
 RE: [Algorithms] Re: Quaternion handedness From: Richard Fabian - 2002-11-27 15:18:33 ```> So why can't we just > adopt math's convention of using predominantly right-handed > operations and > live saner lives where we never have to have a thread like this again? > hear hear! i x j should be equal to k. y rotated pi/2 about x should be z. ```
 RE: [Algorithms] Re: Quaternion handedness From: Jon Watte - 2002-11-27 18:54:59 ```> y rotated pi/2 about x should be z. This is the case in both left-handed and right-handed coordinate systems. Cheers, / h+ ```
 Re: [Algorithms] Re: Quaternion handedness From: Thatcher Ulrich - 2002-11-27 21:26:00 ```> > So why can't we just adopt math's convention of using > > predominantly right-handed operations and live saner lives where > > we never have to have a thread like this again? The least significant byte should have the lowest address! -- Thatcher Ulrich http://tulrich.com ```
 RE: [Algorithms] Quaternion handedness From: Tyson Jensen - 2002-11-22 18:41:04 ```Huh? We wrote an entire game in left-handed coordinates and we never noticed any "magic" preference for right-handedness in matrices. I am unclear as to why arithmetic would care what hand humans tend to prefer. What happens is that care must be taken when copying algorithms out of books that might be making handed-ness assumptions. I'd bet money that lhA * lhB = right handed space is a result of a bias in code, not in the math. If you have a left-handed world and use left-handed transforms your stuff will remain left-handed. I recommend a constant matrix that can be applied to convert a matrix from left-handed to right-handed and another one that goes in reverse. I'd recommend doing all your quaternion stuff in (pick a hand) space. If a matrix is (other-handed) then convert the matrix to the (correct-handed) space, convert to quaternion, do whatever, convert back, and then convert the (correct-handed) matrix back into an (other-handed) matrix. Trying to maintain left-handed quaternions and right-handed quaternions is just compounding the problem of having both left-handed coordinate spaces and right handed coordinate spaces. -----Original Message----- From: gdalgorithms-list-admin@... [mailto:gdalgorithms-list-admin@...] On Behalf Of Joseph, William Sent: Friday, November 22, 2002 9:55 AM To: 'gdalgorithms-list@...' Subject: RE: [Algorithms] Quaternion handedness If I understand matrix stuff correctly, a rotation-only matrix is always right-handed - even when working in a left-handed coordinate system. If your rotation matrix is left-handed, transforming a space by it will cause that space to switch handedness. For example.. object space A is left-handed and object->world rotation matrix B is left-handed. Applying B to A will result in the object appearing right-handed in world-space... I think. To construct the rotation matrix correctly, you have to do it in the correct space. I'm not familiar with tangent-space transforms.. but you may be able to do this by converting the left-handed basis to right-handed, extracting the rotation, then converting back to left-handed. I suggest experimenting.. -Will -----Original Message----- From: Joe Ante [mailto:joeante@...] Sent: 22 November 2002 16:23 To: gdalgorithms-list@... Subject: [Algorithms] Quaternion handedness Hi, I am trying to convert tangent space 3x3 matrices for dot3 product bumpmapping to quaternions. I want to convert these 3x3 matrices into quaternions to do the objectspace- tangentspace transformation, because I need to slerp my tangentspace transform when doing geomorphing on my chunk lod mesh. The tangentspace orthonormal bases are sometimes right handed, sometimes left handed. Unfortunately my matrix to quaternion algorithm seems not to work on left handed matrices. (I am using the algorithm availible at magic-software) Is there any way to represent a left-handed matrix as a quaternion? What do I have to do to convert my left-handed orthonormal matrix into a quaternion? Joe Ante ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ GDAlgorithms-list mailing list GDAlgorithms-list@... https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=6188 ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ GDAlgorithms-list mailing list GDAlgorithms-list@... https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=6188 ```