#### Archived

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

# 3D Movement Math; Trig City

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

## Recommended Posts

##### Share on other sites
Bear with me as this is critical for you to understand how to handle 3D orientations. You really need to stop thinking in terms of Euler angles (yaw, pitch, roll) when you want to do full 3D movement of a spaceship. It works fine with something like a Quake viewpoint when you only usually Yaw, sometimes pitch, and seldom if ever roll.

However, in a flight sim this will be a real problem for you. Assume your order of rotations is Yaw, Pitch, Roll. In my notation (somewhat standard for CG but different for most math people) that is Y, X, Z rotations. Now say your ship is in some arbitary orientation like (10, 0, 90). Visualize that orientation with your hand. Now say the player pulls back on the stick at this time. The expected behavior would be that the pitch increases by 45 degrees or something. Try that with your hand and see where you are pointing.

However, you can''t just add 45 to the pitch. That would give you (10, 45, 90). Again use your hands and see why that is wrong. Since the roll is 90, the 45 should be added to the yaw.

A much easier approach is to use a better 3D orientation rep (o-rep) then Euler angles. You will see lots of people talk of matrices or quaternions. It doesn''t really matter what you use but that it allows you to combine rotations easily. What you will do is take your initial orientation (0,0,0) and convert that to your o-rep. This is easy and any basic 3D book or article will cover that.

Now when you want to turn, you take how you want to turn, say (0, 45, 0) and convert it to your o-rep. Combine this with your current orientation (usually matrix or quaternion multiply) and away you go.

Matrices have a nice property that will be useful for your ship. You can directly extract the forward direction vector at any time. Very useful for moving ahead so I would recommend that o-rep but up to you.

Now wasn''t that better than a simple answer like "Use Matrices, dude..."

-Jeff

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 18
• 19
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633362
• Total Posts
3011531
• ### Who's Online (See full list)

There are no registered users currently online

×