Battle Bott
New member
- Joined
- Jul 27, 2008
- Messages
- 1
I am trying to make an artillery piece for a video game. I have determined the absolute pitch and yaw needed to hit the target. The problem is that I can only set the pitch and yaw of the gun relative to the base plate of the gun.
Here is a picture of what I mean:
In this picture the pitch and yaw of the gun are about 45 and 45, and the base is rotated to 0,0,0
If this base plate is oriented like that, it works fine. If I rotate the base plate at all though, it aims off.
What I need is a set of equations that changes the angle of the gun to compensate for the rotation of the base.
Example:
If I rotate the base plate to 0,45,0 it turns 45 degrees to the left. I then need to adjust the yaw of the gun from 45 to 0 to aim it back to it's original position. Quite simple, basic subtraction. That is fine and dandy if I am only changing the rotation around yaw. But what if the gun is aimed at 123,32 and I rotate the base plate to 345,92,12? What should the new gun angle be?
I don't know how to phrase this mathematically, I guess changing the coordinate axes in polar notation?
I don't know any good ways to start this, except for this roundabout way:
Change the angle of the gun into a vector (x,y,z point) using some trig, rotate that vector using the equations on this page, then convert that vector back into angles. This does destroy the roll component, but for this application I think that is acceptable. I believe I can do this method without help, but it seems like the complicated way.
Is there a simpler solution?
Here is a picture of what I mean:
In this picture the pitch and yaw of the gun are about 45 and 45, and the base is rotated to 0,0,0
If this base plate is oriented like that, it works fine. If I rotate the base plate at all though, it aims off.
What I need is a set of equations that changes the angle of the gun to compensate for the rotation of the base.
Example:
If I rotate the base plate to 0,45,0 it turns 45 degrees to the left. I then need to adjust the yaw of the gun from 45 to 0 to aim it back to it's original position. Quite simple, basic subtraction. That is fine and dandy if I am only changing the rotation around yaw. But what if the gun is aimed at 123,32 and I rotate the base plate to 345,92,12? What should the new gun angle be?
I don't know how to phrase this mathematically, I guess changing the coordinate axes in polar notation?
I don't know any good ways to start this, except for this roundabout way:
Change the angle of the gun into a vector (x,y,z point) using some trig, rotate that vector using the equations on this page, then convert that vector back into angles. This does destroy the roll component, but for this application I think that is acceptable. I believe I can do this method without help, but it seems like the complicated way.
Is there a simpler solution?