#### Archived

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

# math, math, math

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

## Recommended Posts

Okay peoples, here''s my problem, I hope you can help. I have a program that loades a ship from a model, and I can use the keys to rotate it. I use the keys to rotate the world around the model. But when it come to moving the world, thats where I get lost. When I press a key, I want the ship to have the illusion of moving forward, (actually moving the terrain backwards). But when the world rotates around the ship, I can''t just modify the z coordinates on the terrain, because it looks like the ship is sliding sideways. How could I make the terrain move in the right direction, so it looks like the ship is moving forward, instead of sideways. Thanks in advance. The Kid I don''''t know what the future holds, but I know who holds the future.

##### Share on other sites
Are you using a matrix for rotations/translations, or gl calls? Do you have 4DOF or 6 or ??

##### Share on other sites
Have you tried translating before rotating? That is, modifying the z coordinates before you rotate the world around the ship?

/riley

##### Share on other sites
Elixer - I''m only using 4DOF, and I''m using glCalls. Matrix transformations are a little difficult for me now. But I''m learning.

rileyriley - whether I modify the z axis before or after I rotate the world, it still isn''t going to change the ships location on the x axis correctly. Thats what I''m having problems with. Thanks anyway, though.

The Kid

I don''''t know what the future holds, but I know who holds the future.

##### Share on other sites
It''s just some simple trig to make your ship move in the direction it is facing:

shipZ = shipZ + (movementDistance * cos(shipHeadingAngle))
shipX = shipX + (movementDistance * sin(shipHeadingAngle))

Similarly, to move backward, turn the + signs into - signs.
Strafing is a little more involved, but I''m sure you can work it out if you need it later...

NOTE: You may have to tinker with the sign of the Z value you get from this (depending on what handed coord system you are working in for your world coords).
Also, this is locked in the XZ plane... you can modify/add to it to include movement in the Y direction as well (invloves using the pitch angle of the ship as well).

Hope that helps a bit

##### Share on other sites
Not to sound like an idiot (but I probably will anyway!)
I only know of 3 degrees of freedom ,Yaw, Pitch and Roll.
What would the others be in eather 4 or 6DOF ???

##### Share on other sites
quote:
Original post by avianRR

Not to sound like an idiot (but I probably will anyway!)
I only know of 3 degrees of freedom ,Yaw, Pitch and Roll.
What would the others be in eather 4 or 6DOF ???

6DOF = Movement on X, Y, Z & Rotation on X, Y, Z.
4DOF would probably be the same minus one axis.

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632995
• Total Posts
3009773
• ### Who's Online (See full list)

There are no registered users currently online

×