How to find the smallest circle for two tangent points

309 Views Asked by At

I am trying to write a program to draw arcs with directions defined as tangent going between two positions.

I have two vector positions for an arc A and B which defines a start position (A) and end position (B). Each one also has a tangent which defines the direction of travel on the arc.

I am looking to find the smallest possible arc that fits the tangents so i can get the radius, origin and start/end angles (within range of -360 and 360 degrees).

Here is a visual example: enter image description here

So the information i have is:

  1. Start point A (vector)
  2. Start direction which is tangent (unit vector)
  3. End point B (vector)
  4. End direction which is tangent (unit vector)

Looking to find:

  1. Radius
  2. Origin
  3. Start Angle where $\theta$ is in range of [-360,360]
  4. End Angle where $\phi$ is in range of [-360,360]

Is it possible to find the arcs from just this information alone?

Thanks

2

There are 2 best solutions below

3
On BEST ANSWER

The accepted answer provides excellent detail on the underlying structure of the problem. Based on the comments in response to the question, here's framework to get to an actual answer. Get a piece of paper and a pencil out to draw with me.

Given a point $A=(x_a,y_a)$ and a tangent $A'=(x'_a,y'_a)$, and another point $B=(x_b,y_b)$ (assuming B' works as well), we can plop this all in the coordinate plane. The normal passing through A would be $y-y_a = -\frac{x'_a}{y'_a}(x-x_a)$. Call that $N$. Now we need a line from $B$ intersecting $N$ at point $C$ such that $\overline{AC}=\overline{BC}$. Borrowing again from Sammy's answer, we can get the perpendicular bisector of $\overleftrightarrow{AB}$ and find where it intersects $N$. So... we find the midpoint of A and B, and the normal is again, simply the negative inverse of the slope: $y-\frac{y_a+y_b}2=-\frac{x_b-x_a}{y_b-y_a}(x-\frac{x_a+x_b}2)$. Call this $P$.

The intersection of $N$ and $P$ is a system of equations with a few too many variables for me to work through right now (it's 11:30 PM), but it get's you a point. It is the coveted intersection, $C$.

This point is equidistant from $A$ and $B$ by the SAS congruence theorem, if you were wondering. If you draw out $A, A', N, AB,$ and $B$, you'll see $\overline{BC}$ and a few triangles to prove it.

This, at long last, is the center of the circle. The distances AC or BC can serve as the radius. They are equal (see spoiler above).

Now, there are some caveats. This is assuming everything falls into place, as in, the tangent to B allows for an arc to form. Which is what I discuss below.
I program here and there too (Python and Java), so what I would do is have a user defined $A, A',$ and $B$. Unless B lies on A', I'm pretty sure there is always a solution. Any questions, please comment! This is a fun little project I might venture on now...

3
On

3 points on the circumference are sufficient to define a circle. Defining a tangent line is equivalent to defining another 1 point, since 2 points infinitesimally close together define a tangent line.

Given two points A, B on the circumference, the line AB is a chord. The centre of the circle lies on the perpendicular bisector of AB. The smallest possible circle will have AB as diameter - ie the centre of the circle will be at the midpoint of AB. A circle of any diameter larger than this can be drawn.

If you also specify one tangent line, say that at A, then you define the circle uniquely. Effectively you have provided a 3rd point. The centre lies on the intersection of the perpendicular bisector of AB and the normal to the tangent at A.

If you further specify a second tangent line at B, in addition to points A and B and the tangent at A, then you have provided too much information. You have effectively provided a 4th point on the circumference. You have over-constrained the problem. In general there will be no way of drawing a circle - unless the tangent at B fits the circle already determined by points A, B and the tangent at A.