Advertisement

how to get my ship to fly

Started by July 30, 2002 10:24 AM
6 comments, last by Dean Johnson 22 years, 3 months ago
First let me explain what I am working on. I have a 3d engine that uses frames. Each frame has a position represented by (float x, float y, float z), a velocity represented by (float x, float y, float z), also the yaw, pitch and roll of the frame all represented by floats. The frames do translate down to the other frames. Now my question. How should I set my velocity when I don’t know the amount to add to each of the X, Y, and Z floats? If I have not added and Yaw, Pitch or Roll then just setting the Z velocity works. But how do I calculate the velocity when I change the Yaw Pitch and Roll. Thanks
Sorry - had to delete what I posted because I saw lots of flaws in my trig.

[edited by - Bankie on July 31, 2002 2:50:52 PM]
Advertisement
OK, I think it''s this:

x-velocity = velocity * sin(yaw) * cos(pitch)
y-velocity = velocity * sin(pitch)
z-velocity = velocity * cos(yaw) * cos(pitch)

I don''t think the roll affects any of the velocities - only the orientation. No doubt someone will reply and tell me I''m talking cack, but hey, I tried.
It''s better to use a vector to represend the rotation (I mean direction) of your ship instead of Euclidean angles (yaw, pitch, roll) like you use now. Once you got it to work with vectors and found the rotate-around-arbitrary-axis matrix, you will feel like God
And after that you can even try quaternions.
Just out of interest, are you learning from The Zen of Direct3D Game Programming? I wondered because I read that book and it left out many fundamentals including the one you''re describing.
I didn't read any game programming book at all (yet). Most things I tried to figure out myself, or I got help on this forum and flipcode. And there are tutorials on the web of course.

[edited by - Lode on July 31, 2002 3:49:22 PM]
Advertisement
Bankie ~

U speak Irish - Conas atá tú?
U speak scotland irish and its different but still.
You'll Never Beat The Irish!
Ciamar a tha thu, Cuchulainn? Na, I don''t really speak any flavour of Gaelic - Just plain old ugly Glasgwegian.

This topic is closed to new replies.

Advertisement