#### Archived

This topic is now archived and is closed to further replies.

# 3d motion matrix

This topic is 6931 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

i need a matrix that is suitable for aircraft. (i.e. roll and pitch) where can i obtain one, or how can i make one? i''ve tried already, but i''m gettin so damn frustrated cuz the code doesn''t work, i was wondering if somebody had already done the matrix. would it be pitch then roll or roll then pitch? a2k

##### Share on other sites
Hi a2k,

I was reading some stuff about rotations yesterday (whilst avoiding real work ), and in my journeys learned about Gimble Lock (curse ye Gimble... whoever you are).

From what I could gather at a quick skim (haven''t read what I gathered properly yet), the order to do rotations is:

rotate around x axis (pitch)
rotate around y axis (yaw)
rotate around z axis (roll)

The other way to avoid it is to use quaternions, but I still haven''t sat down long enough to learn about them yet... imaginary numbers shudder .I thought I''d leave that in high school.

-------------
squirrels are a remarkable source of protein...

##### Share on other sites
yeah, i''ve never heard of quaternions till recently, and i''d rather stick to the ol'' rotational trig functions. i''m probably just not plugging them in right or something. darn it, i wanna see some loop d loops.

a2k

##### Share on other sites
I had vehicles similar to aircraft is my last game. Here is the order I used:

roll
pitch
yaw

Here, rolling will always rotate the craft about the axis going straight "thru" the craft (from tail to nose). Pitch will always be relative to the horizon (even if the craft is rolled 90 degrees). Yaw will of course change the direction of the craft relative to the world.

This won''t really simulate how a real aircraft''s control stick achieves roll and pitch -- I don''t think any ordering will do that for you.

##### Share on other sites
gotcha. thanks alot. yeah, i don''t think IS possible to mimic the real thing, but whatever feels good in gameplay and looks good on the screen is good enough for me.

now all i gotta do is figure out how to plug it all into my eqns. what i have is the (curtime-prevtime)/freq provides me the incremental distance, and i''m using this as my scalar "radius" for my coefficients to the sin and cos terms. is this right, or am i using the incremental distance wrong? (is it okay to assume that this is the radius for all directions?)

a2k

##### Share on other sites
Quaternions are sweet. The d3d sdk includes matrix or rotation conversion and math functions so you don''t even have to know how they work. Quaternion functions are also similar to matrix functions.
Interpolations are a pain in the ass any other way. My old camera functions, using axis rotations, used to have a bug where at 180 degrees from the character''s forward it would start spinning around the character, faster and faster, now I use quaternions and life is a joy.

##### Share on other sites
okay, sounds like i''ll be looking into quaternions.....

a2k

##### Share on other sites
Make sure you construct a matrix seperately for each axis. Then multiply your coods by each matrix seperately. Example:

Coords * xRot = NewCoords
NewCoords * yRot = NewCoords
NewCoords * zRot = NewCoords

This way, your rotations are RELATIVE to each other, as opposed to fixed to the real axis which is what you get with:

Coords * ( xRot * yRot * zRot ) = NewCoords

##### Share on other sites
okay, well, now i have a working matrix for my aircraft, but the problem is that when i want to roll the aircraft, it wants to roll in wide circles, as opposed to on it''s local z axis. any ideas?

a2k

##### Share on other sites
You are not ''centering'' the plane befor rotation.
so when you rotate it, it rotates around the world origin not its own.
think of a stick with a model plane on one end if you hold the othe end and rotate the stick about your hand the plane moves in an arc.(thats how I think of it)

To fix this problem take away the planes origin from all the points/vertexs in the plane befor rotation them then add the origin back at the end.

I''m sure ther are better ways of doing it but I''m still learing myself.

-Delvar

• 15
• 13
• 35
• 39