3

Let $\mathbf{p}(t)$ parametrize a jordan curve in the plane with the interval $[0, \ 1]$.

How can I find the smallest circle that encloses all points of this curve?

This question relates to the Smallest-circle problem

Examples:

  1. If $\mathbf{p}$ describes the boundary of a polygon, the circle would be the one that contains all the vertices
  2. If $\mathbf{p}$ describes the circle, then the bounding circle would be equal to $\mathbf{p}$.

Basically I'm looking for an algorithm to find this circle.

I thought about using an algebraic approach: find three parameters $t_0$, $t_1$ and $t_2$ to maximize the radius over these three variables. From this question we get the expression

$$r = \left| \left(z_1-z_0\right) \cdot \dfrac{w-|w|^2}{w-\overline{w}}\right|; \ \ \ \ \ \ w = \dfrac{z_2-z_0}{z_1-z_0}$$

With $z_0$, $z_1$ and $z_2$ being the complex numbers generated by the position of $\mathbf{p}$ at values $t_0$, $t_1$, $t_2$

To find the maximum radius, I would use Newton's method with some starting values, but is there another way?

Example: Reduce the problem to one of finding the circle that passes through $n$ points, the candidates, then the problem is easier.

  1. Set the candidates the points which $\mathbf{p}$ is not analitic, at the joints
  2. Add the points with smallest curvature to the candidates
  3. Compute the baricenter, move it to the origin and add the furtherest point.
  4. Divide the curve by segments, find the bounding circle of each segment, and then find the biggest circle that encloses all the smaller circles

Notes:

  1. $\mathbf{p}$ is limited
  2. $\mathbf{p}$ is analitic by parts
  3. $\mathbf{p}$ doesn't intersect itself
  4. $\mathbf{p}$ is closed
Carlos Adir
  • 1,394
  • Unclear if you are after a mathematical expression of a solution, or after a concrete algorithm. –  Oct 22 '24 at 11:34
  • "this approach is very expensive, the radius expression is too big": please explain. –  Oct 22 '24 at 11:35
  • 1
    Some approximation may be obtained simply by identifying four maximum and minimum values of $x$ and $y$, then constructing a rectangle covering the curve and subscribing a circle on the rectangle. For a better result one might construct an up-to-eight-gon by identifying maximum and minimum values of $x,$ $y,$ $x-y$ and $x+y$, and then subscribing a circle on the polygon. We can get better approximations by taking more directions to delimit the convex hull of $p$ closer, but that will never guarantee the exact result... – CiaPan Oct 22 '24 at 11:53
  • @YvesDaoust The mathematical expression of the solution depends highly on the jordan curve treat. Seeking properties that helps finding the circle is desirable. I inserted the expression for the radius, and the derivatives to use in Newton's method are not trivial. – Carlos Adir Oct 22 '24 at 18:48

2 Answers2

2

For an algorithmic solution, which will be approximate, you can,

  • flatten the curve(s), i.e. decompose it in successive segments that do not deviate from the curve by more than a specified distance;

  • construct the bounding circle of the vertices; this can be done on all points, or only on the extreme points, obtained by a convex hull algorithm.

In some specific cases, such as when the curve is made of circular arcs, an exact solution is possible, but can be difficult. The above solution will work with any curve, with a controllable degree of accuracy.


For a more analytical solution, you can consider the function that associates to a point $(x,y)$ the farthest distance to the [parametric] curve, obtained by maximizing

$$(x-u(t))^2+(y-v(t))^2$$ for $t$ in the definition range. The stationary points are the solutions of

$$(x-u(t))u'(t)+(y-v(t))v'(t)=0$$ and they correspond to extrema of the radius. The maximum maximorum must be retained. Now we have a function $r(x,y)$ and maximize it by canceling the gradient.

Alternatively, we can consider the minimization problem of

$$(x-u(t))^2+(y-v(t))^2$$ under the constraint $$(x-u(t))u'(t)+(y-v(t))v'(t)=0,$$ which can be done with Lagrange multipliers. Additional conditions are necessary to obtain the minmax solution.

E.g. consider the circle $u=\cos(t),v=\sin(t)$. After simplification, the maximum distance condition is $$x\sin(t)-y\cos(t)=0,$$ giving the expression of the squared radius

$$\left(\sqrt{x^2+y^2}+1\right)^2.$$

This function is clearly minimized at $x=0,y=0$, with $r=1$.


There is also a parasitic solution corresponding to the minima of

$$\left(\sqrt{x^2+y^2}-1\right)^2,$$ which are on the circle itself and correspond the minima of the distance.

  • For the approximative solution, the given circle can be always smaller than the searched circle, depending on the jordan. Meaning, take a Cardioid with $\mathbf{p}(t)=\left(\cos t (1+\cos t), \ \sin t (1+\cos t)\right)$ as example: the bounding cicle has center $(2/3, 0)$ and radius $4/3$, having only one point of contact at $(2, 0)$. Although at the limit the obtained circle will be the same as the searched one, it will highly depend on the density of sample points around $(2, 0)$ – Carlos Adir Oct 24 '24 at 11:07
  • For the analytical solution, I did not get what would be the "stationary points". From what I understood from your solution, you find minimums and maximums $r^2 = \min_{x, y} \max_{t} (x-u(t))^2+(y-v(t))^2$. Then, when you say the constraint $(x-u)u' + (y-v)v'=0$ : you mean it should/must be valid for all domain of $t$ or you mean that if given $t$ is a point of the bounding circle, it satisfies this equation ? – Carlos Adir Oct 24 '24 at 11:14
  • @CarlosAdir: the condition only holds at the stationary points for fixed $x,y$, of course. –  Oct 24 '24 at 12:20
1

I haven't fully established this, but you might find it useful so I want to give you the idea sooner rather than later. I need to do some additional reading, but I think the approach is promising, and I will come back to edit this comment if this turns out to be justifiable.

Modified problem

Let $p$ be a piece-wise $C^1$, bounded, simple, closed curve in $\mathbb{R}^2$. Find the smallest enclosing circle for this curve.

Approach

If we find the largest distance between two points on this curve, we can use these two points to construct a line segment corresponding the diameter of the enclosing circle.

Perform a translation so that the origin lies in the interior of the curve.

Use Lagrange multipliers to find the points on the curve farthest from the origin, say $P$ and $Q$.

The midpoint $\bigg(\dfrac{P_x+Q_x}{2},\dfrac{P_y+Q_y}{2}\bigg)$ gives the center of the enclosing circle, and $\dfrac{||P-Q||}{2}$ gives the radius.

Apply the reverse translation on the center of this circle (e.g. if your first translation was $T(x,y)=(x+a,y+b)$, now apply $T^{-1}(x,y)=(x-a,y-b)$). This brings the center of the circle enclosing the translated curve to the same relative position with respect to the original curve.

Now draw a circle of radius $\dfrac{||P-Q||}{2}$ around that point. This circle encloses the original curve.

  • This does not work. In the first place, the distance function might have a single maximum. Or up to an infinity. –  Oct 22 '24 at 18:38
  • Thank for your answer, it works for most cases but not all. A counter-example is a equilateral triangle with vertices $(-1, \ 0), (1, \ 0), (0, \ \sqrt{3})$. But the idea of computing the maximum distance between two points, gives two of the three points that defines the bounding circle. I will work on that – Carlos Adir Oct 22 '24 at 19:02
  • @CarlosAdir: there are cases such that the circle is only tangent twice to the curve. –  Oct 22 '24 at 19:39
  • @YvesDaoust The distance function can't blow up to infinity because the curve is assumed to be bounded. The curve must have a maximum within each of the quadrants (regions separated by coordinate axes), and you'd compare the distances of the maxima in opposite quadrants. – om harmoni Oct 22 '24 at 20:11
  • @CarlosAdir This approach does indeed fail for the triangle, but it fails in an interesting way. On an equilateral triangle, you have three points satisfying the maximum in-set distance, namely, the vertices. Picking any two of those lands you on the boundary of the curve, so not in the interior of the curve. I wonder if the approach can be amended so that if you're forced to pick between equidistant pairs of points, you average all of them instead. At least for the equilateral triangle, this would land you in the center. I'll try to work it out when I catch enough free time. – om harmoni Oct 22 '24 at 20:39
  • My intuition here is drawing from this class of problems https://en.wikipedia.org/wiki/Smallest-circle_problem.

    Since algorithms exist for arbitrary finite sets of points, it feels like the curve version amounts to reducing the problem to the "furthest from the center of mass" points, and then treating it like the finite case.

    Since you're assuming the curve to have some nice properties, you have a lot of structure to work with, and Lagrange multipliers work really well for this kind of optimization.

    – om harmoni Oct 22 '24 at 20:44
  • I never spoke about the distance blowing to infinity. You did not mention quadrants before, but this still does not work. –  Oct 22 '24 at 21:05