Tangent to a Circle From a Distant Point

Helper tool in geometry creation

Posted by Sourabh Bhat on Jun 28, 2019

In this article

1. The tool

image
Fig. 1: Schematic diagram of the problem


Inputs:
\(r=\)
\(x_O=\)
\(y_O=\)
\(x_P=\)
\(y_P=\)
Angles:
\(\theta_1=\) \(\theta_2=\)
Tangent locations:
\(T_1=\)
\(T_2=\)
Click the CALCULATE button above to compute the solution for the entered values. The Fig. 1 shows the symbols used in the results.

2. Introduction

Recently, I was working with a friend on a problem requiring CFD simulation. To do the simulation, we needed to recreate a geometry from a research paper. It was a simple axi-symmetric geometry, a part of which is shown in Fig. 2.

image
Fig. 2: Partial geometry from the research paper

This is a fully defined geometry and we could have easily created it using a geometric software such as Solidworks or Catia, by applying necessary constraints of tangency. But we were working with Ansys ICEM meshing software. We knew the position of the center of the circle, its radius and the point at which the ramp begun. Here, I have indicated them as point \(O\) and point \(P\) respectively (see Fig. 1 and Fig. 2). If only we knew where the tangent touches the circle (Point \(T\) in Fig. 1), or the angle at which the radial line touches the tangent (angle \(\theta\) in Fig. 1), we could draw the line from point \(P\) to point \(T\).

This problem seems straightforward at first glance, and we thought so as well. But, it is difficult to solve it without an iterative approach. So, I developed a tool written in JavaScript and HTML (see Sec. 1) to do exactly that and provide the solution. I am putting it here, in hope that it would be useful to someone. For technical details on how the tool works continue to read Sec. 3 below.

3. How does it work?

A tangent line to a circle has a property that it is perpendicular to the radial line at the point of intersection. That is, line \(OT\) is perpendicular to line \(TP\). Which means that if we represent these lines as vectors, then the dot product of the two vector has to be zero (property of the dot product that is very very important and used way too often). The two vectors are created by joining \(T\)-\(P\) and \(O\)-\(T\). Mathematically, they are obtained by subtracting the coordinates of point \(P\) from point \(T\) and subtracting coordinates of point \(T\) from point \(O\). So we obtain the following vector equation:

$$ \overrightarrow{OT}=\left[\begin{array}{c} r\,\cos\left(\theta\right)\\ r\,\sin\left(\theta\right) \end{array}\right] $$
(1)
and,
$$ \begin{align}\overrightarrow{TP} &= \overrightarrow{P}-\overrightarrow{T} \\\implies \overrightarrow{TP} &= \overrightarrow{P}-\left(\overrightarrow{O}+\overrightarrow{OT}\right)\end{align} $$
(2)
The dot product between the two vectors is zero,
$$ \begin{align}\overrightarrow{OT}&\cdot\overrightarrow{TP} = 0\\\implies \overrightarrow{OT}&\cdot\left(\overrightarrow{P}-\left(\overrightarrow{O}+\overrightarrow{OT}\right)\right) = 0\end{align} $$
(3)

Writing it more explicitly, we get,

$$ \left[\begin{array}{c}r\,\cos\left(\theta\right)\\r\,\sin\left(\theta\right)\end{array}\right]\cdot\left[\begin{array}{c}x_{P}-x_{O}-r\,\cos\left(\theta\right)\\y_{P}-y_{O}-r\,\sin\left(\theta\right)\end{array}\right]=0 $$
(4)
which gives us the equation,
$$ r\,\cos\left(\theta\right)\,\left(x_{P}-x_{O}-r\,\cos\left(\theta\right)\right) +r\,\sin\left(\theta\right)\,\left(y_{P}-y_{O}-r\,\sin\left(\theta\right)\right)=0 $$
(5)
and can be simplified to,
$$ \left(x_{O}-x_{P}\right)\,\cos\left({\color{blue}\theta}\right)+\left(y_{O}-y_{P}\right)\,\sin\left({\color{blue}\theta}\right)+r=0 $$
(6)

It is obvious that we can have two solutions to this problem, or no solutions if the point lies inside the circle. The first solution to eq. (6) can be obtained by using the Newton-Raphson method and initializing the iteration such that it converges to one of the sides. The second solution can be similarly obtained. The code decides if there is no solution if it is unable to converge within 100 iterations.

4. Closing remarks & video

Interestingly, "Bintang ASWAM" has contributed two different ways of calculating analytical solutions to angles and tangent points. His solutions I have not yet verified his solutions are available at: Solutions

So now that you know how it works go ahead and use the tool whenever you need it. Feel free to write to me if it is useful or if you find any bugs.

Thanks for using this tool… :)

Watch the video below for an animated treat.


Video 1: Animated description of the problem and tool

Beta testing note: This page is automatically generated using a tool developed by me (inspired by \( \LaTeX \)'s cross-referencing). Please report any formatting errors (or cross-referencing errors) so that it can be corrected in all posts. Thank You!

Comments / Feedback

Note: Comments will appear after review, which may take upto 24 hrs.