   concatenating rotation around different origins
  Hi everybody,Im going mad with a problem I have in developing an application that lets the user rotate a simple object around a specific origin..the rotations are only about the Y and X axis.. the problem is that the origin of rotation can change.now, everything is ok until I change the rotation origin.. it seems like the first rotation changes the axis for the subsequent rotationsexample:rotate 47deg around Yrotate 23deg around Xand everything is fine..then I change the rotation origin and when I, say, rotate 20deg around X, the X axis the object will rotate is not anymore world-X.Im using matrices, and multiply the new rotation mat everytime the origin changes.I switched to quaternions, and got exactly the same results I had with matrices.Is there something Im missing?Thank you :)   
  Assume that an object is transformed by a matrix M so far. An additional rotation R applied about a world axis gives thenR * M(using column vectors; change the order if you're using row vectors). If you want to use another center of rotation, then you have to make the desired center temporarily the origin, i.e. you define another "rotation"R' := T * R * T-1where T denotes the translation matrix to the desired center of rotation. Substition gives thenT * R * T-1 * M;  sorry I was in a bit of a hurry while writin my last post..of course, in order to define a new center of rotation, opportune translations take place..the actual code is something like this:translate(x,y,z);multiply_matrix(m);translate(-x,-y,-z);m is a matrix converted from the rotation quaternionthere is a main matrix k, which gets modified by each translation and rotation, and is reset before each loop, unless there is an origin change, in which case it is multiplied by the new translation/rotation/translation matrix and so forth..I can rotate and translate everything for as long as I want, and everything is ok (k -identity at the beginning- is calculated at each loop).but when I chancge the origin, I get a new x,y,z, reset rotation angles, recalulate m. k (which holds t/r/t around the last origin) is saved and reloaded at each loop, so that the new transformations (t/r/t) add up to the last-origin k.I have to multiply matrices when changing origin, otherwise the rotations will be ok, but the object will suddently change screen position while rendering (the new origin will be in the middle of the screen).the problem is that the new rotations will not refer to the world axis anymore.hope Ivenot been too messy :)   ;  Err, well, I'm sure that I haven't understood ;(Mathematically the precedence is clear: When using column vectors, then the sequenceR1 * vmeans that v is rotated about the global axis as incorporated in R1.Multiplying another rotation on the left (remember: column vectors) ever means to do another rotaton about a global axis.R2 * R1 * vi.e. v is rotated about the global axis as incorporated in R1, and the result of that is rotated about the global axis as incorporated in R2. There is no possibility that a translation changes this.If you accidentally do a multiplication on the rightR1 * R2 * vthen the effect is that you seem to rotate about a local axis.This is because after the first rotationR1you may create a rotationR2' := R? * R2 * R?-1so that the desired local axis becomes temporarily the global one (this is equivalent to the temporary center of rotation concept). Now, since R1 defines the current orientation, it is clear thatR? == R1must hold. Hence after substitution we getR1 * R2 * R1-1 * R1= R1 * R2q.e.d.For row vectors you have to reverse all the matrix products, of course. So, the only explanation I have ATM is: Either you use a wrong order and hence has a mathematical error, or else your implementation is messed up (in which case we need to inspect code).   ;  uh.. hmm..no,implementation is ok.. but you gave me a couple of things to think about..thank you!   