Find coordinates of the rotation center My software is going to control a Laser. I know the Laser's current Position defined as $P_1$ with coordinates $(x,y)$ and the place where it will be after a clockwise rotation around a point $C$, defined as point $P_2$ with coordinates $(x_1,y_1)$.
I have following information:


*

*$P_1 (x,y)$

*$P_2 (x_1,y_1)$

*Distance $d$ from $P_1$ to $C$ (is the same as distance from $P_2$ to $C$)

*There will be two points as a solution. the one i need is the one that is the center point of a CLOCKWISE rotation going from $P_1$ to $P_2$ 


What I need is the $(x_C,y_C)$ coordinates of C.
What would be the easiest way to solve this?
The difficulties I have are 2..
First of all how do i find the 2 possible C points?
And second, how do i determine what point is the one i need?
EDIT: 
Just to clarify: All i know in the beginning is a string: G2 x15 y30 R20 where G2 indicates a clockwise rotation, from the current location (known) to point x15 y30 with a radius of 20. This is all I have to start with.. 
 A: A rotation by an angle $-\theta$ (i.e. clockwise) around a point $C$ can be interpreted as a translation from $C$ to the origin, followed by a rotation of angle $-\theta$ around said origin, and a final translation from the origin back to $C$. Thus: $$R^{-\theta}_C=T^{-1}\circ R^{-\theta}_O\circ T$$
$$R^{-\theta}_C=\begin{pmatrix}1&0&C_x\\0&1&C_y\\0&0&1\end{pmatrix}\begin{pmatrix}\cos\theta&\sin\theta&0\\-\sin\theta&\cos\theta&0\\0&0&1\end{pmatrix}\begin{pmatrix}1&0&-Cx\\0&1&-Cy\\0&0&1\end{pmatrix}$$
$$\therefore R^{-\theta}_C=\begin{pmatrix}\cos\theta&\sin\theta&C_x-C_x\cos\theta-C_y\sin\theta\\-\sin\theta&cos\theta&C_y+C_x\sin\theta-C_y\cos\theta\\0&0&1\end{pmatrix}$$
You know $\theta$, and you know the $x$ and $y$ coordinates of the points $P_1$ and $P_2$, related by:
$$P_2(x,y)=R^{-\theta}_C P_1(x,y)$$
which gives you a system of equations to solve to get $C(C_x,C_y)$.
The expressions for $C_x$ and $C_y$ are not exactly "pretty", but since this is a numerical problem, you should have no problem implementing them:
$$C_x=\dfrac{P_{2,y}\left(1+\sin\theta-\cos\theta\right)+P_{1,x}\left(1-\cos\theta\right)+P_{1,y}\sin\theta}{2-2\cos\theta}$$
$$C_y=\dfrac{P_{2,y}\left(1-\cos\theta-\sin\theta\right)+P_{1,y}\left(1-\cos\theta\right)+P_{1,x}\sin\theta}{2-2\cos\theta}$$

EDIT: since you don't know $\theta$, but know the coordinates of $P_1$ and $P_2$, and the distance $d=||\vec{P_2}-\vec{C}||=||\vec{P_1}-\vec{C}||$:
$$\theta=2\arcsin\left(\dfrac{||\vec{P_2}-\vec{P_1}||}{2d}\right)$$
A: This just comes down to computing an isosceles triangle because
$$\|\vec{P}_1 - \vec{C}\| = \|\vec{P}_2 - \vec{C}\| = d$$
and the angles at $\vec{P}_1$ and $\vec{P}_2$, let's call them $\beta$, are equal. $\|\vec{P}_1 - \vec{P}_2\| =: a$ is known. Use basic trigonometry and you're done.
From Pythagoras we get the triangle's height from
$$h = \sqrt{d^2 - (a/2)^2}$$
and
$$\beta = \arcsin \frac{h}{d}.$$
With the angle between $\vec{P}_2 - \vec{P}_1$ and the x-axis
$$\phi = \arctan \frac{P_{2,y}-P_{1,y}}{P_{2,x}-P_{1,x}}$$
you get
$$\vec{C} = \vec{P}_1 + d \cdot \left(\begin{array}{c}
\cos(\phi+\beta) \\ \sin(\phi+\beta)
\end{array}\right)$$
or in simpler notation
$$C_x = P_{1,x} + d \cdot \cos(\phi+\beta) \\ 
C_y = P_{1,y} + d \cdot \sin(\phi+\beta)
$$
but take care of the sign of $\beta$, which I didn't give much attention.
A: The locus of points which are equidistant from $P_1$ and $P_2$ is the perpendicular bisector of $\overline{P_1P_2}$. The center of the rotation will be on that line.
$$
\begin{align}
C
&=\frac{P_1+P_2}2+t\,(P_1-P_2)^R\\
&=P_2+\frac{P_1-P_2}2+t\,(P_1-P_2)^R\\
\end{align}
$$
where $(x,y)^R=(-y,x)$ rotates $(x,y)$ counter-clockwise $\frac\pi2$. If $t\gt0$, then the rotation about $C$ from $P_1$ to $P_2$ is clockwise between $0$ and $\pi$.
$$
d=|C-P_2|=|P_1-P_2|\sqrt{\frac14+t^2}
$$
Thus,
$$
t=\sqrt{\frac{d^2}{|P_1-P_2|^2}-\frac14}
$$
Therefore,
$$
C=\frac{P_1+P_2}2+(P_1-P_2)^R\,\sqrt{\frac{d^2}{|P_1-P_2|^2}-\frac14}
$$
