17
$\begingroup$

See also: answers with code on GameDev.SE

How can I find out the arc length of a Bézier curve? For instance, the arc length of a linear Bézier curve is simply:

$$s = \sqrt{(x_1 - x_0)^2 + (y_1 - y_0)^2}$$

But what of quadratic, cubic, or nth-degree Bézier curves?

$$\mathbf{B}(t) = \sum_{i=0}^n {n\choose i}(1-t)^{n-i}t^i\mathbf{P}_i$$

  • 0
    What do you mean by "distance traveled"? Are you referring to the distance traveled along the curve in a given parameterization?2010-11-28
  • 0
    @Alex Yes. http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Generalization2010-11-28
  • 7
    The arclength of a Bézier curve can be very complicated; for a quadratic Bézier you have a complicated expression involving logarithms/inverse hyperbolic functions, and for a cubic Bézier one now requires elliptic integrals.2010-11-28
  • 0
    @J.M. Wow... o_o I think I'll just use an approximation by linear interpolation.2010-11-28
  • 2
    If you have *Mathematica* : `Integrate[(Sqrt[#1 . #1] & )[D[Sum[{Subscript[x, i + 1], Subscript[y, i + 1]}*Binomial[2, i]*(1 - u)^(2 - i)*u^i, {i, 0, 2}], u]], u]`2010-11-28
  • 0
    (The cubic version looks more nightmare-ish than that!)2010-11-28
  • 1
    @muntoo: You'd probably be better off using a numerical quadrature routine here instead of trying to tease out an explicit closed form expression, FWIW. Note that the answer given by Williham in the Game Dev site uses numerical quadrature (Gaussian for one, and a clever subdivision into line segments or essentially a trapezoidal rule for the other) in the page for the cubic case he linked to.2010-11-28
  • 4
    From what you write about "resolution", I'm wondering whether you're solving the right problem. As far as I remember, the best way to draw Bézier curves isn't to substitute successive values of $t$, but to recursively divide them in two until the parts can be satisfactorily drawn as lines?2011-09-04
  • 0
    Arc length is given by $$s=\int_a^b\sqrt{1+\left(\frac{dy}{dx}\right)^2}dx.$$ Maybe you can use a Bézier parametrization and the integral.2016-06-28

5 Answers 5