Solving Simple tank problem with matrices

Ok, so I’ve tried a few times to figure this out and keep getting the answer wrong. I’ve attached a picture to make it more clear.

You have a target point, which is relative to a missile. I want to find the target location relative to the tank turret’s coordinate system.

target location relative to missile coordinate system = (8, -4)
tank location relative to missile coordinate system = (4, 0)
turret is rotated 45 degrees from the front of the tank
The coordinate system is X out the front of a vehicle and Y to the left

Using basic algebra, you can find the answer almost trivially. I want to understand the process when using rotation matrices.

I thought the answer should be -

R(-45)R(90)(target pos - tank pos)

Where R(x) represents the rotation matrix of x degrees.

I seem to end up getting the correct number (4* sqrt(2), 0), but I end up with it being negative, which isn’t correct.

So what is the correct way of doing this?

Cheers,
Dr. A>

PS - I was using column vectors, so my rotation matix looked like:


cos x  -sin x
sin x  cos x

so P2 = RP1

| x2 |  =  | cos x  -sin x | | x1 |
| y2 |     | sin x   cos x | | y1 |

your Y goes up for the screenshot - but the actual physical screen coordinates point down. could this be the problem?

It shouldn’t be the problem. The problem is wholly independent of 2d drawing in java. So, my Y going left and X going out the front of a vehicle should be acceptable. It might be a tad confusing, but I believe its fine.

I tried to make this problem independent of right and left hand coordinate systems, by reducing it to a 2d one.

Other thoughts?

Dr. A>