The answer is given to you by the sign of (x1-cx)(y2-cy) - (y1-cy)(x2-cx)
.
Proof:
Let A
be the direction from C
to (x1,y1)
, expressed as an angle measured anticlockwise from the X axis; B
be the direction from C
to (x2,y2)
, expressed the same way; and r
be the radius of the circle. Then (x2,y2)
is to the right of (x1,y1)
, as seen from C, if A-B
lies between 0 and pi or between -2pi and -pi (that is, if sin(A-B)
is positive), and to the left if A-B
lies between -pi and 0 or between pi and 2pi (that is, if sin(A-B)
is negative).
Now,
(x1,y1)=(Cx + r cos A, Cy + r sin A)
(x2,y2)=(Cx + r cos B, Cy + r sin B)
So
(x1-Cx)(y2-Cy) - (y1-Cy)(x2-Cy)
= (r cos A)(r sin B) - (r sin A)(r cos B)
= - r^2 (sin A cos B - cos A sin B)
= - r^2 (sin (A-B))
which has the opposite sign to sin (A-B)
.