# point on grid along a circle's edge?

• Sep 20th 2009, 11:35 PM
Mikemc
point on grid along a circle's edge?
I'm sorry, I don't even know what this is called so if it is in the wrong subforum, I apologize again. While I am asking for the work to be done for me, I'm not just some dumb kid (I'm 28) so either an answer or simply point me in the right direction would also be ok.

I'm trying to make a boat with independantly rotating turrets mounted to it. I need those turrets to stay in the same spot on the hull regardless of the direction the boat is facing. This is for a system that only uses (x,y) coordinates, and basic mathematics (+,-,x,\).

As you can see the boat's rotation point is currently (8.0,8.0) and the turret is at (9.0,8.0). As the boat turns that point will move and I would like to know at each frame it's current location on the grid. Like if the boat rotated 12 degrees counter-clockwise, where will the turret end up? (This coord will then be used to position the turret manually)

- Mike
• Sep 21st 2009, 03:21 PM
pflo
Quote:

Originally Posted by Mikemc
I'm trying to make a boat with independantly rotating turrets mounted to it. I need those turrets to stay in the same spot on the hull regardless of the direction the boat is facing. This is for a system that only uses (x,y) coordinates, and basic mathematics (+,-,x,\).

As you can see the boat's rotation point is currently (8.0,8.0) and the turret is at (9.0,8.0). As the boat turns that point will move and I would like to know at each frame it's current location on the grid. Like if the boat rotated 12 degrees counter-clockwise, where will the turret end up? (This coord will then be used to position the turret manually)

The y-coordinate is the sine of the angle (plus 8 since the circle's origin is at y=8) and the x-coordinate is the cosine of the angle (plus 8 since the circle's origin is at x=8). If the radius of your circle were something other than 1, you would need to multiply the sine and cosine times the radius before doing the addition.

Note that this is when the angle is measured in a counterclockwise direction, so a movement in the clockwise direction would be a negative angle. Also, make sure you're using the correct units when doing this (degree mode, all length units the same, etc).

This should work no matter which direction the boat is facing - even travelling backwards.
• Sep 21st 2009, 10:37 PM
Mikemc
Ah.. so if the boat is at say, (76,55) and is rotated +24 degrees, then the turret should be at ~(76.9,55.4) and +48 degrees is ~(76.6,55.7).

...cool! (Clapping)

Thanks a ton! Now I just need to figure out how to use only whole numbers but that'll be my doing (Nod)

- Mike