I'm having two vectors p and q starting at point O (origin). These vectors are known, as well as the origin point is. I know the angle α (alpha). Given a circle with arbitrary radius r, I want to be able to calculate point of tangency X (and ideally also C). I'm interested in a first solution, that fits in the angle. I just can't figure it out.



The angle $\angle XOC$ is $\alpha/2$ as can be seen by symmetry. Hence $r = \lvert OC\rvert\cdot \sin (\alpha/2)$, and $\lvert OX\rvert = \lvert OC\rvert \cdot \cos (\alpha/2)$. Thus $\lvert OX\rvert = r\cdot \cot (\alpha/2)$, $\lvert OC\rvert = r\cdot \csc (\alpha/2)$.

After clarification of the used coordinate system in the comments, given the angles $\phi$ and $\psi$ between the positive $x$-axis and the two rays, where the point $X$ shall be on the ray with angle $\phi$, the opening $\alpha$ is the (absolute) difference $\lvert \psi -\phi\rvert$. The distance from $O$ is is calculated above, and the direction is given by $(\cos\phi,\sin\phi)$, so the coordinates of $X$ are

$$(r\cot(\alpha/2)\cos\phi,\, r\cot(\alpha/2)\sin\phi),$$

and the coordinates of $C$ are

$$\left(r\frac{\cos ((\phi+\psi)/2)}{\sin(\alpha/2)},\, r\frac{\sin((\phi+\psi)/2)}{\sin(\alpha/2)}\right).$$

Unfortunately, I don't see how to reduce the calls to the trigonometric functions easily.

Assuming a Cartesian coordinate system with $O$ at the origin $(0,0)$, and $Q = (q_x,0)$ with $q_x > 0$, and $P = (p_x,p_y)$ with $p_x > 0,\; p_y > 0$, the symmetry gives us that the $x$-component of $C$'s coordinates is $\lvert OX\rvert$, and the $y$-component is of course $r$, so

$$C = (r\cot (\alpha/2), r).$$

We have $\lvert OX\rvert = r\cot (\alpha/2)$, and the direction is given by $(\cos \alpha, \sin\alpha)$, so

$$X = r\cot(\alpha/2)(\cos\alpha,\sin\alpha),$$

and using $\cos\alpha = \cos^2 (\alpha/2) - \sin^2 (\alpha/2) = 1-2\sin^2(\alpha/2)$; $\sin\alpha = 2\sin(\alpha/2)\cos(\alpha/2)$, we obtain

$$\begin{gather} \cot(\alpha/2)\cos\alpha = \cot(\alpha/2) - 2\cos(\alpha/2)\sin(\alpha/2) = \cot(\alpha/2) - \sin\alpha\\ \cot(\alpha/2)\sin\alpha = 2\cos^2(\alpha/2) = 1 + \cos\alpha \end{gather}$$


$$X = \bigl(r(\cot(\alpha/2) - \sin\alpha), r(1+\cos\alpha)\bigr).$$

  • $\begingroup$ That calculates only a distance. The distance itself seems to be OK though. Can you include the point as well. I'm asking because it will probably involve somehow additional trigonometric function(s). I'm programmer, so I'd like to be sure, there's no faster (lower number of trigonometric functions) solution when both distance, and point are calculated at once. $\endgroup$ – SmartK8 Aug 31 '13 at 14:52
  • $\begingroup$ For the point itself, we must use some coordinates. Is it okay to assume Cartesian coordinates with $O$ the origin, and $q$ on the positive ray of the $x$-axis, and the $y$-component of $p$ positive? $\endgroup$ – Daniel Fischer Aug 31 '13 at 14:56
  • $\begingroup$ Yes. p is a line (vector) from O[ox, oy] to P[px, py]. $\endgroup$ – SmartK8 Aug 31 '13 at 14:58
  • $\begingroup$ I've added coordinates. If your coordinate system is different, I hope you know how to rotate/reflect things to get the coordinates you need, otherwise, specify your coordinate system, then I can do it. $\endgroup$ – Daniel Fischer Aug 31 '13 at 15:23
  • $\begingroup$ I've calculated it for the picture (roughly of course). In picture r=23, α=225° (0° being direction to east).. the X resulted in [39, 39]. That seems OK, but then I've tried it for α=45° that returned [39, 39] as well, but I'd expect on of them to be negative [-39, -39]. The system I'm using is standard 2D graphics. (On monitor) Left is -x, right is +x, top is -y, bottom is +y. I'd be able to accommodate for mirroring, but this returns +/+ values for opposite directions. It is possible, that I've miscalculated of course (always a possibility). $\endgroup$ – SmartK8 Aug 31 '13 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.