Airplane rotation around its own axes

Started by
3 comments, last by ibolcina 22 years, 8 months ago
I have an airplane in world space. How to represent its orientation? How to rotate it around its axes? Iam using directx8. I have seen many examples where there is a class representing an 3d object. They also have methods like rotate, but this methods allways apply to world axes! I need it to rotate around its own axes! If you have some source it would be great! bye and thanx & please ivan bolèina
Advertisement
Apply the rotation to the body before you rotate it into world space. E.g. suppose the object''s rotation matrix is R, and you want to rotate it about the x-axis, with a matrix X.

The matrix XR gives the result of taking it''s existing rotaiton and rotating about the x-axis. But the matrix RX rotates it about the x-axis in its frame of reference before rotating it into the world space,

If you want to update its position by rotating it about its own X axis use something like

R = RX

Where X gives the appropriate rotation for the time step between calculations. Using X as a rotation about the x-axis is just an example: this works with any valid rotation matrix.

The mathematics looks identical with quaternions, but with one possible difference. There are two ways of using quaternions, one where the multiplication order is the same as matrices, the other where all multiplications are done the other way round. Which you use depends on the API: there''s no single standard so if you''re not sure just try it both ways to see which works.
John BlackburneProgrammer, The Pitbull Syndicate
I feel so damm stupid.

Wouldn''t R=RX just rotate current rotation matrix around X axis in world-space?

I would kill for some code. I suppose I understand matrix(or affine transformations), but this is major headache. Damm!

thanx for help
  void CAvatar::RotateLeft(float fElapsed_sec)	{	D3DXQUATERNION dr;		float Turn_r = m_fTurnRate_rps * fElapsed_sec;		D3DMath_QuaternionFromAngles(dr.x, dr.y, dr.z, dr.w, 0.0f, Turn_r, 0.0f);	m_qFacing = dr * m_qFacing;	m_bTurned = TRUE;	}  


Each object you want to rotate keeps a quaternion around that stores it''s current rotation. Quaternions are kinda like vectors for rotations. So you build a q that represents the relative change in rotation, and mutliple the avatar''s current facing quaternion by this, and voila, the resultant q is the facing you want.

For an airplane simutalation you will need something better than D3DMath_QuaternionFromAngles(dr.x, dr.y, dr.z, dr.w, 0.0f, Turn_r, 0.0f); - I use this when they hit the turn left key.


I think you can use Q''s with magnitude to represent torques.


Magmai Kai Holmlor
- Not For Rent
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
> I think you can use Q''s with magnitude to represent torques.

You should use vectors for torque, angular velocity, angular momentum, etc. They are related by simple vector equations, e.g.

T = dL/dt
L = Iw

T = torque, L = angular momentum, w = angular velocity, I = moment of inertia


Angular velocity and the rotation quaterninon are related by the equation

dq/dt = 1/2 w * q

Here w is treated as a quaternion so it can be multiplied by q, but is still a vector quantity. As with most things to do with quaternions the multiplication order depends on the quaterion ordering convention. This equation is used to update the rotation, e.g. using Euler''s method to get

q = q + 1/2 w * q * time_step
John BlackburneProgrammer, The Pitbull Syndicate

This topic is closed to new replies.

Advertisement