# Calculating the position of a point along an arc

I have computer program I am writing where I need to calculate the position of a point(called P) when rotated around another point.

I am attempting to come up with a general function/formula I can use to calculate this point P but my Maths is a little weak & I cannot identify what arc/tangent formula I am meant to use.

Can you assist me to come up with a formula I can use to calculate point P for rotations that can be both positive & negative?

I know how to calulate the length of the line between points (14,446) & (226,496) but not how to calculate the blue point x,y position - BTW: the length of this line is the same as the line between the blue point & (14,446)

len = sqrt( (496-446)^2 + (226-14)^2 );
= 227.56;

-

Let's say that the point you're rotating is $(p_x,p_y)$ (your lower-right red point), that the center of rotation is $(c_x,c_y)$ (your middle red point), and that the rotation has magnitude $\theta$ (positive being counterclockwise, your angle being $165°$). Then the resulting point (your blue point) is at $$(c_x+(p_x-c_x)\cos\theta+(c_y-p_y)\sin\theta,\;\;c_y+(p_y-c_y)\cos\theta+(p_x-c_x)\sin\theta).$$
@JakeM: By "magnitude of the rotation" I mean the size and direction of the rotation—it shouldn't matter if your programming 0° is where a mathematical 90° would be, since that doesn't affect how far your red point has to rotate to become your blue point. Positive angles will rotate in the counterclockwise direction, while negative angles will rotate in the clockwise direction (this is assuming that your positive $y$-axis is 90° counterclockwise from your positive $x$-axis; if it's 90° clockwise, then positive angles are clockwise as well). – Isaac Jan 28 '12 at 6:33
@JakeM: Assuming Math.sin and Math.cos are expecting angles in degrees, var mid = {x: 14+((226-14)*Math.cos(165))+((446-496)*Math.sin(165)), y: 446+((496-446)*Math.cos(165))+((226-14)*Math.sin(165))}; (swap 446 and 496 in the expression for x) should be right, but looking at your picture again, it looks like your positive $y$-axis goes downward ($0$ at the top, positive below that), so you may need to change the 165 to -165. – Isaac Jan 28 '12 at 6:47