Raptisoft
11-28-2004, 03:37 PM
Hi all,
I have a question for some of you real mathheads out there. I have a matrix class that encapsulates matrix functions (essentially, it just wraps D3DX functions).
I'm trying to draw text on a slant. Can one of you tell me what the difference is between these two code chunks? The premise is to rotate an object around a center after offseting the object 100 pixels along X. Then draw it with the center at 100,100.
Matrix myMatrix;
myMatrix.Translate(100,0);
myMatrix.Rotate2D(45);
myMatrix.Translate(100,100);
Okay, that one works. Now, I thought this would do the exact same thing:
Matrix myMatrix;
myMatrix.Translate(100,0);
Matrix myOtherMatrix;
myOtherMatrix.Rotate2D(45);
myOtherMatrix.Translate(100,100);
myMatrix*=myOtherMatrix;
That second one doesn't work properly. The object is rotated as though it was at 0,0-- around its own arbitrary center. But it draws in the correct location, meaning that the translate in myOtherMatrix definitely DID happen, but seems to get applied before the rotate instead of after! Is this some artifact of matrix multiplication that I don't know about?
Thanks a skajillion!
--John
I have a question for some of you real mathheads out there. I have a matrix class that encapsulates matrix functions (essentially, it just wraps D3DX functions).
I'm trying to draw text on a slant. Can one of you tell me what the difference is between these two code chunks? The premise is to rotate an object around a center after offseting the object 100 pixels along X. Then draw it with the center at 100,100.
Matrix myMatrix;
myMatrix.Translate(100,0);
myMatrix.Rotate2D(45);
myMatrix.Translate(100,100);
Okay, that one works. Now, I thought this would do the exact same thing:
Matrix myMatrix;
myMatrix.Translate(100,0);
Matrix myOtherMatrix;
myOtherMatrix.Rotate2D(45);
myOtherMatrix.Translate(100,100);
myMatrix*=myOtherMatrix;
That second one doesn't work properly. The object is rotated as though it was at 0,0-- around its own arbitrary center. But it draws in the correct location, meaning that the translate in myOtherMatrix definitely DID happen, but seems to get applied before the rotate instead of after! Is this some artifact of matrix multiplication that I don't know about?
Thanks a skajillion!
--John