Adjusting pitch and yaw by pitch yaw and roll

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:
1217211866-clip-1kb.png

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?
 
I believe the simpler method would be by matrix notation.

I assume you have not studied matricies, so the method you are using will work.

assume a xyz cordinate system
If we rotate about z , thru the angle @ we have the new x'y'z' cordinates are:

x' cos@ sin@ 0 x
y' = - sin@ cos @ 0 y
z' 0 0 1 z

multiplying
x'=cos@ x +sin@y +0z
y'=-sin@x+cos@y +0z
z'=z

if you then rotate about the y axis ( a simple way to visualize it is to say the 1 moves to the middle position and all trig signs move the same way )

By this method all rotations become matrix algebra problems.
i am afraid this is not of much help to you, but it is the only simple way i know of to handle rotating coordinate systems.

I used this method in the 50's when determining position coordinates for inertial navigators.
 
Top