6
$\begingroup$

I would like to know how I can get the coordinates of four control points of a Bézier curve that represents the best approximation of a circular arc, knowing the coordinates of three points of the corresponding circle. I would like at least to know the solution to this problem in the case where two of the known circle points are the two ends of a diameter of the circle.

$\endgroup$
3
  • $\begingroup$ Can we assume that the second point is half-way along the circular arc? $\endgroup$
    – bubba
    Commented Feb 25, 2016 at 12:34
  • $\begingroup$ No, it can be any point in the circular arc $\endgroup$
    – Neo
    Commented Feb 25, 2016 at 13:25
  • $\begingroup$ It gets much more difficult if the interior point isn't mid-way along the arc. I suggest you begin by figuring out the circle through the three points (i.e. compute its center and radius). Type "circle through three points" into your favorite search engine. $\endgroup$
    – bubba
    Commented Feb 26, 2016 at 1:20

3 Answers 3

3
$\begingroup$

You can use the following ways to find the control points of a cubic Bezier curve for approximating a circular arc with end points $P_0$, $P_1$, radius R and angular span A:

Denoting the control points as $Q_0$, $Q_1$, $Q_2$ and $Q_3$, then

$Q_0=P_0$,
$Q_3=P_1$,
$Q_1=P_0 + LT_0$
$Q_2=P_1 - LT_1$

where $T_0$ and $T_1$ are the unit tangent vector of the circular arc at $P_0$ and $P_1$ and $L = \frac{4R}{3}tan(\frac{A}{4})$.

Please note that above formula will give you a pretty good approximation for the circular arc. But it is not "the best" approximation. We can achieve an even better approximation with more complicated formula for the $L$ value. But for practical purpose, above formula is typically good enough.

$\endgroup$
8
  • 1
    $\begingroup$ What do you mean by "angular span" ? @fang $\endgroup$
    – Neo
    Commented Feb 28, 2016 at 18:53
  • 1
    $\begingroup$ Angular span is the spanning angle of that circular arc. For example, a semicircle has 180 degree of angular span and a full circle has a 360 degree of angular span. Be sure to use radian (not degree) in the computation of tan(). $\endgroup$
    – fang
    Commented Feb 28, 2016 at 21:05
  • $\begingroup$ Since tangents are unit-length, shouldn't the formula for $L$ be multiplied by $R$? $\endgroup$
    – CygnusX1
    Commented Mar 23, 2020 at 18:50
  • $\begingroup$ You are correct. Thanks for catching this. I will revise the formula. $\endgroup$
    – fang
    Commented Mar 24, 2020 at 1:43
  • $\begingroup$ @fang Could you describe "an even better approximation with more complicated formula for the L value"? $\endgroup$
    – Ivan Bunin
    Commented Jan 2, 2022 at 19:11
3
$\begingroup$

For a unit semi-circle centered at the origin, the points are $(1,0)$, $(1, \tfrac43)$, $(-1, \tfrac43)$, $(-1,0)$. Translate, rotate, and scale as needed.

If the end-points of the diameter are $\mathbf{P}$ and $\mathbf{Q}$, proceed as follows:

Let $\mathbf{U}$ be a vector obtained by rotating $\vec{\mathbf{P}\mathbf{Q}}$ through 90 degrees. Then the control points are $\mathbf{P}$, $\mathbf{P} + \tfrac23 \mathbf{U}$, $\mathbf{Q} + \tfrac23 \mathbf{U}$, $\mathbf{Q}$.

Pseudocode is as follows

Vector A = Q - P;
Vector U = new Vector(-A.Y, A.X);   // Perpendicular to PQ
double s = 2.0/3.0;                 // Scale factor
Vector[] controlPoints = { P, P + s*U, Q + s*U, Q };

For general circular arcs, complete details are given in "Good approximation of circles by curvature-continuous Bézier curves", by Tor Dokken, Morten Dæhlen Tom Lyche, Knut Mørken, Computer Aided Geometric Design Volume 7, Issues 1–4, June 1990, Pages 33-41.

$\endgroup$
4
  • 1
    $\begingroup$ Thanks for you answer in the case of a semi-circle, I actually made a mistake in my question, I want to know the formula not only for a semi-circle but for any circular arc. I edit my post @bubba $\endgroup$
    – Neo
    Commented Feb 25, 2016 at 12:24
  • $\begingroup$ Thanks, do you have an idea for the general case where the two points are not the ends of the circle's diameter ? @bubba $\endgroup$
    – Neo
    Commented Feb 25, 2016 at 13:18
  • $\begingroup$ $4/3$ is the value that makes the spline also go through $(0,1)$. If you don't insist on this condition you can do a bit better, e.g. the minimum of $\int_0^1 (x(t)^2 + y(t)^2 - 1)^2 \, dt$ is attained when $4/3$ is replaced by $(172 \, / \, 99)^{1/2}$ which is about $1.3181$. $\endgroup$ Commented Feb 26, 2016 at 3:46
  • $\begingroup$ @NoamD.Elkies. Yes, and the value that minimizes $\max\{x^2(t) +y^2(t) -1: 0 \le x \le 1\}$ (which is often more meaningful) is something different again. See paper by Dokken at al. that I referenced. $\endgroup$
    – bubba
    Commented Mar 1, 2016 at 13:07
1
$\begingroup$

(I needed a method that was robust in the limit $r\to \infty$, here's what I came up with based on fang's answer.)

We want to approximate an arc through points $A$ and $B$ with radius $r$. If instead we have 3 points, we can use the side lengths $a, b, c$ of the triangle formed by the points to calculate $r$:

$$\begin{aligned} s &= \frac{1}{2}(a + b + c) \\ r &= \frac{a b c}{4 \sqrt{s (s - a) (s - b) (s - c)}} \end{aligned}$$

Let $C_0 = \frac{1}{2}\left(A + B\right)$ be the midpoint of $A$ and $B$. Let $C = C_0 + D$ be the control point of the quadratic Bézier curve through the points $A$ and $B$ with its midpoint at the midpoint of the arc (where $D$ is perpendicular to $AB$); then $$|D| = 2 r \left(1 - \cos\left(\sin^{-1}\left(\frac{|A - B|}{2r}\right)\right)\right)$$ Naively computed this has catastrophic cancellation, so I used series expansion, with $x = |A - B|, y = \frac{x}{r}$: $$|D| = x y \left(\frac{1}{4} + \frac{1}{64} y^2 + \frac{1}{512} y^4 + \frac{5}{16384}y^6 + \frac{7}{131072} y^8 + O(y^{10})\right)$$ If $y$ is not small enough for the series to converge quickly enough, divide the original arc into smaller pieces and retry.

This quadratic Bézier is not a good approximation of a circular arc. But if we split the original arc in half (the midpoint of the arc is $C_0 + \frac{1}{2} D$), and then find the quadratic control points $C_A$ and $C_B$ for each half as above, they can be modified to give the control points $Q$ of a cubic Bézier curve for the original arc:

$$\begin{aligned} Q_0 &= A \\ Q_1 &= A + \frac{4}{3}\left(C_A - A\right) \\ Q_2 &= B + \frac{4}{3}\left(C_B - B\right) \\ Q_3 &= B \\ \end{aligned}$$

Diagram:

construction of Q_1

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .