Advertisement

MORE trig yaw, pitch and roll questions!

Started by March 16, 2002 07:07 PM
2 comments, last by Cybertron 22 years, 11 months ago
I have a major problem with my game. I need to calculate the yaw pitch and roll of a projectile fired from a turret so far I have: RAD_TO_DEG(atan2(0-vecMovement.z, 0-vecMovement.x)) + ship->fYaw This almost works perfectly, but it doesnt takew into account the PITCH of the ship, so when I flip it upside down it is wrong! So how on earth do I get the yaw relative to the way the ship is pointing!
Yaw, pitch, and roll are bad concepts. Don''t use them. If you do, you''ll slow down your own learning and be generally sorry.

If you have a transformation matrix for the ship, use that for the bullet. If you don''t have a transformation matrix yet, then just use the forward vector and the right vector to build a matrix (cross-product them to get the up-vector).

-Jonathan.
Advertisement
I know yaw pitch and roll suck, but I need them to control the position of the ship. I use the DX functions to make a vector out of the ships movement, and to point to the target. I need to check weather the target is in the firing arc though, which has gotten me stumped

I am very close to a solution, I have a vector that points forwards relative to the ship, and one with the same length pointing towards the target.

All I need now is to find the angle between the 2 vectors (they intersect at the origin) and it SHOULD work!

All I need is the yaw, which is on the X-Z plane, so I can ignore the Y and use 2d math
If all you need is the angle now...

D3DXVec3Normalize V1, V1
D3DXVec3Normalize V2, V2
a = D3DXVec3Dot(V1, V2)
degree = (1 - a) * 90

This topic is closed to new replies.

Advertisement