Rotating a Vector Tangent to a Circle I've been searching the internet all day for this particular case and can't find a single word on the subject - whether that's my poor searching or the subject is obscure, I do not know. I am also not particularly fluent with mathematical jargon, so forgive my fumbling explanation. Hopefully one of you may re-phrase my problem after I present it.
This Tangent Chord Angle diagram is the closest visual representation I can find for describing my dilemma. I'll be referring to points from this diagram, although it doesn't demonstrate the problem itself, only the starting conditions of my problem.
I have been trying to write a program that will rotate a vector TP from a point T tangent to circle O until that vector essentially describes a chord on the circle (possibly TA if the magnitude of A equals the magnitude of P).
I know:


*

*T, the initial tangent point

*TP, the initial vector from T

*O, the circle on which T lies

*The radius of circle O


I have no clue what to do to get that vector to "fit" inside the circle. I understand there are two possible chords depending on the direction of rotation - I'll be using whichever angle is closer to the vector's original angle.
Again, forgive my inability. I'm afraid it would take considerably longer for me just to learn how to more appropriately describe the problem.
 A: As it turns out, the tangent-chord angle is actually just what you want.
But you want the particular tangent-chord angle for the chord that
is the same length as your vector.
That is, you want to find the angle $\angle ATP$,
where a point $A$ on the circle $O$
such that $\lvert TA\rvert = \lvert TP\rvert$ 
(that is, the lengths of the vectors from $T$ to $P$ and to $A$ are equal).
Moreover, of the two possible solutions, you want the one that
gives the smaller value of $\angle ATP$.
Then since $T$ and $A$ are both on the circle, they are at equal
distances from $O$, and $\triangle AOT$ is an isoceles triangle
with side lengths $\lvert OA\rvert=\lvert OT\rvert=r$, where $r$ is the radius of the circle.
Let $M$ be the midpoint of $TA$;
then $\triangle OMT$ and $\triangle OMA$ are two congruent right triangles
with hypotenuse $r$ and leg length $\frac12 \lvert TA\rvert$
opposite the angle at $O$,
and $$\angle AOT = \angle AOM + \angle MOT = 2\angle MOT.$$
But by the tangent-chord angle theorem, $\angle ATP = \frac12\angle AOT$,
so $\angle ATP = \angle MOT$.
And by the definition of the sine of an angle,
$$\sin(\angle MOT) = \frac{\frac12 \lvert TA\rvert}{r}.$$
Noticing that
$$\frac{\frac12 \lvert TA\rvert}{r} = \frac{\lvert TA\rvert}{2r}
= \frac{\lvert TP\rvert}{2r},$$
we find that
$$\sin(\angle ATP) = \sin(\angle MOT) = \frac{\lvert TP\rvert}{2r}.$$
You know $\lvert TP\rvert$ and $r$, so you just need to solve
for $\angle ATP$ in the equation above.
The solution is
$$
\angle ATP = \arcsin\left( \frac{\lvert TP\rvert}{2r} \right);
$$
of the possible angles that would solve the equation for
$\sin(\angle ATP)$, this chooses the smallest angle, which is the one you want.
The mathematical function $\arcsin$ is implemented as asin
in many software libraries; the output of this function
is usually an angle measured in radians.
