Re: Rotation
- From: "Poldie" <Poldie@xxxxxxxxx>
- Date: 16 Nov 2006 14:47:11 -0800
Richard [Microsoft Direct3D MVP] wrote:
[Please do not mail me a copy of your followup]
"Poldie" <Poldie@xxxxxxxxx> spake the secret code
<1163709878.874531.26960@xxxxxxxxxxxxxxxxxxxxxxxxxxx> thusly:
Richard [Microsoft Direct3D MVP] wrote:
[Please do not mail me a copy of your followup]
"Poldie" <Poldie@xxxxxxxxx> spake the secret code
<1163687868.342551.189710@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> thusly:
I think a lot of people would just store the object's orientation in a
quaternion and then create the rotation matrix directly from the
quaternion.
I don't understand quaternions, and I'm trying to only use code that I
understand. I thought quaternions are only required for fairly
advanced stuff, like getting a camera to move smoothly from a to b
while looking at c. I just want to rotate a cube (for example) !
A quaternion is a concise representation of an arbitrarily orientable
coordinate frame, which is just what you want. But hey, I agree that
if you don't understand quaternions, don't use 'em :-). But there are
lots of tutorials out there on the net that explain quaternions so I'd
guesstimate that in an hour or so of reading you would understand
them.
I like that you rate my maths knowledge such that I can get my head
around it in just an hour! Perhaps I'll try again - who knows, maybe
I'll understand it this time!
Either that or its compose the three matrices for the object's three
principal axes together.
Could you expand on this a little, or point me at a link, or something?
I think the key point for rotations is that you have to rotate
*around* something. When you construct a pure rotation matrix, its
rotating about the origin. So if you want something to rotate about
its center, you have to compute
T(-C)*Rx(theta)*Ry(phi)*Rz(gamma)*T(C)
Where C is the center point and theta, phi and gamma are your angles
of rotation around the three principal axes. Things will always look
weird if you don't do the translation to the origin and back. They
can look "almost right" if you object just *happens* to have a center
that is near, but not on, the origin.
Sure, I understand that. I'm talking about rotating the objects in my
game, so they are currently all in local space (object space). So I
should be able to rotate them, then translate them into world space.
But my problem is that I don't store the angles (theta,phi and gamma in
your example). I don't say `here's my triangle - I want to rotate it 30
degrees on the X, 12 on the Y and -2 on the Z`. I say `lets init the
object with an x vector of (1,0,0), y of (0,1,0) and z of (0,0,1).
Then, then I want to rotate it around, say, the z axis anti-clockwise,
I rotate the x and y vectors around the z, so that my x vector is now
perhaps (.9, .1,0), my y is (-.1,.9,0) and z still (0,0,1). I made
those numbers up but you see what I mean.
If I have to get an angle to do the rotation then I think I need to get
the angle between the original x vector of (1,0,0) and the new
(.9,.1,0). If that angle was 1 degree then I could then do the rotation
by calling .RotateZ(1). (Well, I'd need to convert degrees to rads but
you get the idea).
It's sounding like perhaps I should just store the current orientation
of the object using your three angles. I'm just worried that that'll
make it hard/impossible for me to subsequently be able to say `roll
left 5 degrees` (which is pretty simple at the moment) because if I've
rolled 90 degrees clockwise, then pitched up 90 degrees then trying to
pitch up 90 degrees will actually roll it.
I've been meaning to print out bits of your book - thanks for that.
Page 10 of that link is a good example of scary maths, though.
.
- Follow-Ups:
- Re: Rotation
- From: Richard [Microsoft Direct3D MVP]
- Re: Rotation
- References:
- Rotation
- From: Poldie
- Re: Rotation
- From: Richard [Microsoft Direct3D MVP]
- Re: Rotation
- From: Poldie
- Re: Rotation
- From: Richard [Microsoft Direct3D MVP]
- Rotation
- Prev by Date: Re: Rotation
- Next by Date: Re: UI in DirectX9 managed
- Previous by thread: Re: Rotation
- Next by thread: Re: Rotation
- Index(es):
Relevant Pages
|