TITLE: Distance from point in circle to edge of circle
QUESTION [5 upvotes]: The situation is as follows:
I have a circle with a diameter of $20$ and a center at $(0,0)$.
A point $P$ inside that circle is at $(2,0)$.
How do I calculate the distance from $P$ to the edge of the circle for a given angle $\theta$?

REPLY [3 votes]: A different solution without having to solve an equation is by rotating the axis back and forth. (more suitable for mathematical programs)
r is the radius of the circle.
O is the origin at [0, 0].
P is any point within the circle [Px, Py].
Q is point at perimeter of the circle
θ is angle from point P to Q positive with x-axis
R is the rotation matrix  with R = [cosθ -sinθ; sinθ cosθ]
R' is the inverse rotation matrix
Now rotate such that x-axis is parallel to PQ.
Describe point P and Q as P'and Q' in the new axis orientation. 
P' = R'P
because of the parallel alligned the following formula's are true:
Q' = [Q'x, Q'y] = [r * cosφ, r * sinφ], 
with φ is angle from O to Q (positive with rotated x-axis)
Q'y = P'y
Substitute φ for P'y gives:
Q'x = r * sin(arccos(P'y/r))
Now all that is left to do is rotate the axis back how it was
Q = RQ'
you can now use pythagoras to get the length PQ