Finding the component of a vector tangent to a circle Problem
Given a vector and a circle in a plane, I'm trying to find the component of the vector that is tangent to the circle. The location of the tangent vector is unimportant; I only need to know its magnitude and whether it is directed clockwise or counter clockwise about the circle.
Background (just in case you're interested)
I'm writing an iPhone app that displays a dial. The user is allowed to spin the dial by dragging it around with his finger. If the user then flicks his finger in some direction (and lets go), the dial should continue to spin before coming to a stop. For added realism, the amount of spin should be directly proportional to the velocity of the flick. In other words, I'm simulating the inertia and momentum of the dial.
The OS already provides a vector describing the velocity and direction of the flick. Note that if it happened to be tangential to the dial, I could simply find the magnitude of the vector and use it directly as the amount of spin. But the flick could be in any direction -- even outside the dial. A flick along the radius of the dial, for example, should result in no motion. Therefore, I need to find:


*

*The component of the flick vector that is tangential to the dial

*Whether this tangent vector is clockwise or counter clockwise around the dial


With this information, I can calculate how much spin should be put on the dial by finding the magnitude of the tangent vector.
Illustration
That might not be clear, so here's a diagram to illustrate:



*

*$V$: flick vector

*$P$: start point of the vector

*$D$: midpoint of the vector

*$T$: tangent vector I'm trying to find

*$E$: point where the tangent vector touches the circle

*$R$: radius of the circle

*$C$: center of the circle

*$T'$: another way of looking at the tangent vector (for an alternate approach described later)

*$V_{2}$, $V_{3}$: other possible flick vectors


My approach
My first approach was to derive an equation for the tangent line ($T$).
The midpoint $D$ would be given by:
$D = ( P_{x} + \frac{V_{x}}{2}, P_{y} + \frac{V_{y}}{2})$
The slope $m$ of line $\overline{C D}$ would be:
$m = \frac{D_{y} - C_{y}}{D_{x} - C_{x}} = \frac{P_{y}+\frac{V_{y}}{2} - C_{y}}{P_{x} + \frac{V_{x}}{2} - C_{x}}$
And then the equation for line $\overline{C D}$ would be:
$y - C_{y} = m(x - C_{x})$
$E$ would be the intersection of that line and the circle:
$(x - C_{x})^{2} + (y - C_{y})^{2} = R^{2}$
By solving for $x$ and $y$ in the $\overline{C D}$ equation and substituting into the circle equation, I get:
$x = C_{x} ± \frac{R}{\sqrt{1 + m^{2}}}$
$y = C_{y} ± \frac{R}{\sqrt{1 + m^{2}}}$
These $x, y$ values are the coordinates of point $E$.
Now I finally have an equation for the tangent line $T$. I simply use the perpendicular slope of line $\overline{C D}$ and the coordinates of point $E$:
$y - E_{y} = - \frac{1}{m}(x - E_{x})$
I've verified that my work is correct by plugging in some numbers, but I'm not sure what to do next. I still don't have the magnitude of the tangent vector.
Alternate approach
As an alternate approach, I thought of ignoring $T$ altogether and considering $T'$ instead, since I only need to know the magnitude of the tangent vector. But in the right triangle I only know the length of the hypotenuse ($|V|$). That's not enough information to determine the length of $T'$.
Or, if I could somehow determine the $x, y$ components of $T'$, then I believe the dot product ($V \cdot T'$) would give me the magnitude of the tangential component of the vector V. (Please correct me if I'm wrong.) But I'm not sure how to get those values in the first place.
How can I proceed? Thanks for any suggestions.
 A: I think that the simplest way would be like this:
Firstly, find the angle between (the line from the center of the circle to the midpoint of the Vector) and (the Vector itself). (Do you know how to do this? If not, comment and we can expand). I'm capitalizing the V in the Vector we start with to distinguish it.
Once you have this angle $\theta$, then the length of the tangent you're looking for is given by $L\sin^{} \theta$, where $L$ is the length of the Vector. And whether it's clockwise or counterclockwise should come from your calculation of the angle.
Or we could do everything with complex numbers. If the angle that the midpoint-line makes with the positive real axis is $\theta$, then multiply the complex representatives of the endpoints of the Vector by $e^{-i\theta}$, and calculate the imaginary part of the difference $d$ between the endpoints. Then positive and negative correspond to positive and negative imaginary part, respectively. And for that matter, the tangent vector is given by $e^{i \theta} \text{Im}(d)$, where Im stands for the imaginary part.
If you know some complex, then you'll see we rotated the vector so that our tangent point on the circle is always $(1,0)$, so we took the $y$ component and rotated it back.
A: The vector $T$ is the component of $V$ perpendicular to $CD$. Assuming the center of the circle $C$ is the origin, this is just
$$T = V - \frac{D(D\cdot V)}{\lVert D\rVert^2}.$$
If you want the signed magnitude of the vector, with positive being anticlockwise and negative being clockwise, you should take the cross product of $D/\lVert D\rVert$ and $V$ instead. In two dimensions, the cross product of two vectors is a scalar,
$$
u \times v = \begin{vmatrix}u_x & v_x \\ u_y & v_y\end{vmatrix} = u_xv_y - u_yv_x.
$$
If the circle is not centered at the origin, just replace $D$ with $D - C$ in all of the above expressions.
