Re: Rotation

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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.

.



Relevant Pages

  • Re: Rotation problem
    ... you're going to have to be able to rotate your own vertices within your ... Don't bother with quaternions, either, as they don't gain you anything over ... rotation, translation, scaling, and shearing. ... web site that covers matrix rotation around an arbitrary axis. ...
    (comp.graphics.api.opengl)
  • Re: Rotation
    ... I think a lot of people would just store the object's orientation in a ... I don't understand quaternions, and I'm trying to only use code that I ... I think the key point for rotations is that you have to rotate ... When you construct a pure rotation matrix, ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: Defining Rotations Limits using Quaternions In 3d Space
    ... Since quaternions have 4 components, you would need a 4-dimensional volume ... If you want to stay away from Euler angles, ... rotation as a vector with a certain length. ... I once worked on optimizing such a rotational workspace. ...
    (comp.graphics.algorithms)
  • Re: Matrix -> Angles?
    ... for an equivalent set of angles so I can modify the world as well to ... I don't know much about quaternions, ... The method from my idea describes the orientation using 3 "standard"-axis ... rotation around the 360 deg. axis. ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Matching points to a known grid
    ... > small amount of rotation in the extracted points. ... angles and then pick the angle that gives you the most matches. ... thing about the complex notation is that you can rotate points ...
    (sci.image.processing)