# Composite Bézier curve

Beziergon - The red beziergon passes through the blue vertices, the green points are control points that determine the shape of the connecting Bézier curves

In geometric modelling and in computer graphics, a composite Bézier curve or Bézier spline is a spline made out of Bézier curves that is at least ${\displaystyle C^{0}}$ continuous. In other words, a composite Bézier curve is a series of Bézier curves joined end to end where the last point of one curve coincides with the starting point of the next curve. Depending on the application, additional smoothness requirements (such as ${\displaystyle C^{1}}$ or ${\displaystyle C^{2}}$ continuity) may be added.[1]

A continuous composite Bézier is also called a polybezier, by similarity to polyline, but whereas in polylines the points are connected by straight lines, in a polybezier the points are connected by Bézier curves. A beziergon (also called bezigon) is a closed path composed of Bézier curves. It is similar to a polygon in that it connects a set of vertices by lines, but whereas in polygons the vertices are connected by straight lines, in a beziergon the vertices are connected by Bézier curves.[2][3][4] Some authors even call a ${\displaystyle C^{0}}$ composite Bézier curve a "Bézier spline";[5] the latter term is however used by other authors as a synonym for the (non-composite) Bézier curve, and they add "composite" in front of "Bézier spline" to denote the composite case.[6]

Perhaps the most common use of composite Béziers is to describe the outline of each letter in a PostScript or PDF file. Such outlines are composed of one beziergon for open letters, or multiple beziergons for closed letters. Modern vector graphics and computer font systems like PostScript, Asymptote, Metafont, OpenType, and SVG use composite Bézier curves composed of cubic Bézier curves (3rd order curves) for drawing curved shapes.

Sinc function approximated using a smooth Bézier spline, i.e., a series of smoothly-joined Bézier curves

## Smooth joining

A commonly desired property of splines is for them to join their individual curves together with a specified level of parametric or geometric continuity. While individual curves in the spline are fully ${\displaystyle C^{\infty }}$ continuous within their own interval, there is always some amount of discontinuity where different curves meet.

The Bézier spline is fairly unique in that it's one of the few splines that doesn't guarantee any higher degree of continuity than ${\displaystyle C^{0}}$. It is, however, possible to arrange control points to guarantee various levels of continuity across joins, though this can come at a loss of local control if the constraint is too strict for the given degree of the Bézier spline.

### Smoothly joining cubic Béziers

Given two cubic Bézier curves with control points ${\displaystyle [\mathbf {P} _{0},\mathbf {P} _{1},\mathbf {P} _{2},\mathbf {P} _{3}]}$ and ${\displaystyle [\mathbf {P} _{3},\mathbf {P} _{4},\mathbf {P} _{5},\mathbf {P} _{6}]}$ respectively, the constraints for ensuring continuity at ${\displaystyle \mathbf {P} _{3}}$ can be defined as follows:

• ${\displaystyle C^{0}/G^{0}}$ (positional continuity) requires that they meet at the same point, which all Bézier splines do by definition. In this example, the shared point is ${\displaystyle \mathbf {P} _{3}}$
• ${\displaystyle C^{1}}$ (velocity continuity) requires the neighboring control points around the join to be mirrors of each other. In other words, they must follow the constraint of ${\displaystyle \mathbf {P} _{4}=2\mathbf {P} _{3}-\mathbf {P} _{2}}$
• ${\displaystyle G^{1}}$ (tangent continuity) requires the neighboring control points to be collinear with the join. This is less strict than ${\displaystyle C^{1}}$ continuity, leaving an extra degree of freedom which can be parameterized using a scalar ${\displaystyle \beta _{1}}$. The constraint can then be expressed by ${\displaystyle \mathbf {P} _{4}=\mathbf {P} _{3}+(\mathbf {P} _{3}-\mathbf {P} _{2})\beta _{1}}$

While the following continuity constraints are possible, they are rarely used with cubic Bézier splines, as other splines like the B-spline or the β-spline[7] will naturally handle higher constraints without loss of local control.

• ${\displaystyle C^{2}}$ (acceleration continuity) is constrained by ${\displaystyle \mathbf {P} _{5}=\mathbf {P} _{1}+4(\mathbf {P} _{3}-\mathbf {P} _{2})}$. However, applying this constraint across an entire cubic Bézier spline will cause a cascading loss of local control over the tangent points. The curve will still pass through every third point in the spline, but control over its shape will be lost. In order to achieve ${\displaystyle C^{2}}$ continuity using cubic curves, it's recommended to use a cubic uniform B-spline instead, as it ensures ${\displaystyle C^{2}}$ continuity without loss of local control, at the expense of no longer being guaranteed to pass through specific points
• ${\displaystyle G^{2}}$ (curvature continuity) is constrained by ${\displaystyle \mathbf {P} _{5}=\mathbf {P} _{3}+(\mathbf {P} _{3}-\mathbf {P} _{2})(2\beta _{1}+\beta _{1}^{2}+\beta _{2}/2)+(\mathbf {P} _{1}-\mathbf {P} _{2})\beta _{1}^{2}}$, leaving two degrees of freedom compared to ${\displaystyle C^{2}}$, in the form of two scalars ${\displaystyle \beta _{1}}$ and ${\displaystyle \beta _{2}}$. Higher degrees of geometric continuity is possible, though they get increasingly complex[8]
• ${\displaystyle C^{3}}$ (jolt continuity) is constrained by ${\displaystyle \mathbf {P} _{6}=\mathbf {P} _{3}+(\mathbf {P} _{3}-\mathbf {P} _{0})+6(\mathbf {P} _{1}-\mathbf {P} _{2}+\mathbf {P} _{3}-\mathbf {P} _{2})}$. Applying this constraint to the cubic Bézier spline will cause a complete loss of local control, as the entire spline is now fully constrained and defined by the first curve's control points. In fact, it is arguably no longer a spline, as its shape is now equivalent to extrapolating the first curve indefinitely, making it not only ${\displaystyle C^{3}}$ continuous, but ${\displaystyle C^{\infty }}$, as joins between separate curves no longer exist

## Approximating circular arcs

In case circular arc primitives are not supported in a particular environment, they may be approximated by Bézier curves.[9] Commonly, eight quadratic segments[10] or four cubic segments are used to approximate a circle. It is desirable to find the length ${\displaystyle \mathbf {k} }$ of control points which result in the least approximation error for a given number of cubic segments.

### Using four curves

Considering only the 90-degree unit-circular arc in the first quadrant, we define the endpoints ${\displaystyle \mathbf {A} }$ and ${\displaystyle \mathbf {B} }$ with control points ${\displaystyle \mathbf {A'} }$ and ${\displaystyle \mathbf {B'} }$, respectively, as:

{\displaystyle {\begin{aligned}\mathbf {A} &=[0,1]\\\mathbf {A'} &=[\mathbf {k} ,1]\\\mathbf {B'} &=[1,\mathbf {k} ]\\\mathbf {B} &=[1,0]\\\end{aligned}}}

From the definition of the cubic Bézier curve, we have:

${\displaystyle \mathbf {C} (t)=(1-t)^{3}\mathbf {A} +3(1-t)^{2}t\mathbf {A'} +3(1-t)t^{2}\mathbf {B'} +t^{3}\mathbf {B} }$

With the point ${\displaystyle \mathbf {C} (t=0.5)}$ as the midpoint of the arc, we may write the following two equations:

{\displaystyle {\begin{aligned}\mathbf {C} &={\frac {1}{8}}\mathbf {A} +{\frac {3}{8}}\mathbf {A'} +{\frac {3}{8}}\mathbf {B'} +{\frac {1}{8}}\mathbf {B} \\\mathbf {C} &={\sqrt {1/2}}={\sqrt {2}}/2\end{aligned}}}

Solving these equations for the x-coordinate (and identically for the y-coordinate) yields:

${\displaystyle {\frac {0}{8}}\mathbf {+} {\frac {3}{8}}\mathbf {k} +{\frac {3}{8}}+{\frac {1}{8}}={\sqrt {2}}/2}$
${\displaystyle \mathbf {k} ={\frac {4}{3}}({\sqrt {2}}-1)\approx 0.5522847498}$

Note however that the resulting Bézier curve is entirely outside the circle, with a maximum deviation of the radius of about 0.00027. By adding a small correction to intermediate points such as

{\displaystyle {\begin{aligned}\mathbf {A'} &=[\mathbf {k} +0.0009,1-0.00103]\\\mathbf {B'} &=[1-0.00103,\mathbf {k} +0.0009],\end{aligned}}}

the magnitude of the radius deviation to 1 is reduced by a factor of about 3, to 0.000068 (at the expense of the derivability of the approximated circle curve at endpoints).

### General case

We may compose a circle of radius ${\displaystyle R}$ from an arbitrary number of cubic Bézier curves.[11] Let the arc start at point ${\displaystyle \mathbf {A} }$ and end at point ${\displaystyle \mathbf {B} }$, placed at equal distances above and below the x-axis, spanning an arc of angle ${\displaystyle \theta =2\phi }$:

{\displaystyle {\begin{aligned}\mathbf {A} _{x}&=R\cos(\phi )\\\mathbf {A} _{y}&=R\sin(\phi )\\\mathbf {B} _{x}&=\mathbf {A} _{x}\\\mathbf {B} _{y}&=-\mathbf {A} _{y}\end{aligned}}}

The control points may be written as:[12]

{\displaystyle {\begin{aligned}\mathbf {A'} _{x}&={\frac {4R-\mathbf {A} _{x}}{3}}\\\mathbf {A'} _{y}&={\frac {(R-\mathbf {A} _{x})(3R-\mathbf {A} _{x})}{3\mathbf {A} _{y}}}\\\mathbf {B'} _{x}&=\mathbf {A'} _{x}\\\mathbf {B'} _{y}&=-\mathbf {A'} _{y}\end{aligned}}}

## Fonts

TrueType fonts use composite Béziers composed of quadratic Bézier curves (2nd order curves). To describe a typical type design as a computer font to any given accuracy, 3rd order Beziers require less data than 2nd order Beziers; and these in turn require less data than a series of straight lines. This is true even though any one straight line segment requires less data than any one segment of a parabola; and that parabolic segment in turn requires less data than any one segment of a 3rd order curve.

## References

1. ^ Eugene V. Shikin; Alexander I. Plis (14 July 1995). Handbook on Splines for the User. CRC Press. p. 96. ISBN 978-0-8493-9404-1.
2. ^ Microsoft polybezier API
3. ^ Papyrus beziergon API reference
4. ^ "A better box of crayons". InfoWorld. 1991.
5. ^ Rebaza, Jorge (24 April 2012). A First Course in Applied Mathematics. John Wiley & Sons. ISBN 9781118277157.
6. ^ (Firm), Wolfram Research (13 September 1996). Mathematica ® 3.0 Standard Add-on Packages. Cambridge University Press. ISBN 9780521585859.
7. ^ Goodman, T.N.T (9 December 1983). "Properties of β-splines". Journal of Approximation Theory. 44 (2): 132–153. doi:10.1016/0021-9045(85)90076-0.
8. ^ DeRose, Anthony D. (1 August 1985). "Geometric Continuity: A Parametrization Independent Measure of Continuity for Computer Aided Geometric Design".
9. ^ Stanislav, G. Adam. "Drawing a circle with Bézier Curves". Retrieved 10 April 2010.
10. ^ "Digitizing letterform designs". Apple. Retrieved 26 July 2014.
11. ^ Riškus, Aleksas (October 2006). "APPROXIMATION OF A CUBIC BEZIER CURVE BY CIRCULAR ARCS AND VICE VERSA" (PDF). Information Technology and Control. Department of Multimedia Engineering, Kaunas University of Technology. 35 (4): 371–378. ISSN 1392-124X.
12. ^ DeVeneza, Richard. "Drawing a circle with Bézier Curves" (PDF). Retrieved 10 April 2010.