Angle for pointing at a certain point in 2d space Recently, I have been programming a simple game. Very simple:
There is a tank, and the cannon will aim at whatever position the mouse is at.
Now lets talk about the cannon graphic. The cannon graphic points to the north, with 0 rotation.
Here are the variables I have for my game, and that might be important factors for solving my problem:
Tx = The tank's X position in the world.
Ty = The tank's Y position in the world.
Mx = The mouse's X position in the world.
My = The mouse's Y position in the world.
Also, in this programming language, the greater the Y coordinate, the lower you are. And the less the Y coordinate is, the higher you are. So, Y = 0 means the top.
My problem is, how do calculate the rotation needed for my cannon graphic to "point" to the mouse's position?
Thank you for your time.

Okay, in your coordinates "north" presumably means up, i.e. the direction of decreasing $y$ coordinates.  Let's assume for convenience that all $y$ coordinates are nonnegative, so $y=-1$ is off the display.
From a location $(x_0,y_0)$ to target $(x_1,y_1)$ the angle you want has cosine $(y_0 - y_1)/d$ where $d = \sqrt{(x_1 - x_0)^2 + (y_1 - y_0)^2}$ is the distance location to target.
Taking the arccosine of this gives the absolute value of the angle you want.  For the sign you need to say whether the cannon rotates clockwise or counterclockwise as the angle increases.  If increasing the angle (from zero = up/north) rotates clockwise, then choose a positive sign whenever $x_1 > x_0$ and a negative sign when $x_1 < x_0$.  If $x_1 = x_0$, then the angle is either zero when $y_1 < y_0$ or $\pi$ radians (aka 180 degrees) if $y_1 > y_0$.
