Inflection points of a cubic Bezier

Sep. 2004, Author: Adrian Colomitchi

Abstract

The present article explores the points in which a cubic Bezier curve changes its bending direction: the inflection points. It presents the parametric equation that allows the computation of the inflection point position and the number of this inflection points, showing that there are at most 2.

Dividing a cubic Bezier in its points of inflection will result in a set of curve segments that will have an uniform bending direction: the resulted curve segments will turn either clockwise or counterclockwise, not both. Therefore, the position of the inflection points becomes important in applications where the uniformity of bending direction does matter, e.g. the approximation of cubic Bezier curves by sets of connected quadratic Bezier segments.

A special case is where, even the bending direction stays the same, a cubic Bezier displays a cusp (angle with curved sides). Even the exact conditions for a cubic Bezier to display a cusp is not investigated, this aspect is also touched by the article.

No special mathematical background is necessary to the reader, except the definition of the first and second derivatives and solving second degree equations.

The article is sustained by interactive Bezier applets: to modify the configuration of the anchor/control points, one will need just to click-n-drag them with the mouse pointer.

The relation between the bending direction
and the derivatives of a curve

Inflection points - points where a curve changes the direction of bending.

Parametric curve - a curve described by expressing the position of any and all its points as function of one parameter:
(Px, Py) = (fx(t), fy(t)).
See for example the parametric expression of a cubic or a quadratic Bezier curve in a previous article.

With this definitions, the following statement acts as the basis for this article:

The position of the inflection points of a parametric curve are among the solutions of the equation:

P'(tX P"(t) = 0                           (1)

where:

P'(t) stands for the first derivative vector -  (f'x(t), f'y(t))

 P"(t) stands for the second derivative vector -  (f"x(t), f"y(t))

X stands for the cross product between the two vectors —
i.e. P'(tX P"(t) = f'x(t)•f"y(t) - f'y(t)•f"x(t)

Demonstrating of the above statement is possiblenote 1 but beyond the scope of the article. Still an intuitive justification is still provided: anyone that went skating (skiing, cycling or even running) should remember that, for changing the direction of movement, one should apply a certain force in the direction of intended turn, thus the direction of movement and the one of the applied force should not be coincident. If the two directions are coincident, the trajectory would be a straight line.
To change the direction of trajectory bending, one should change the direction of the applied force from one side of the movement direction to the other side. If this transition is done smoothlynote 2 , there will be a moment when the direction of movement will be colinear (aligned) with the one of the applied force . In this very moment, the trajectory will change its bending direction.
Defining a little bit more exactly the terms:

On the applet below, one can explore the behaviour of the first derivative (figured as an yellow segment) and the second derivative (figured as a magenta segment) in different points of some chosen cubic curves. Different positions on the curve may be obtained by adjusting the t parameter value using the slider below the applet:

  1. Configuration 1 - there is only one location that renders null the cross product between the directions of the first and second derivatives - in this point the two directions are coincident;
  2. Configuration 2 - there is only one location in which the cross product between the directions of the first and second derivatives is null - in this point the two directions are opposite;
  3. Configuration 3 - there are two locations in which the cross product between the directions of the first and second derivatives is null - in one of them the two direction is opposite, while in the other one the directions are coincident;
  4. Configuration 4 - there is a single point where the cross product between the directions of the first and second derivatives is null - it is the first derivative that is null in this point.

Computing the position of inflection points of a a cubic Bezier

As noted above, one should compute the solution of the

P'(tX P"(t) = f'x(t)•f"y(t) - f'y(t)•f"x(t) =  0

equation. For the beginning, a parametric representation for a cubic Bezier that will be more appropriate for derivation is to be obtained: what is making harder the derivation is the presence of the (1-t) terms mixed with t terms in the parametric representation previously derived. For simplifying the computation, in applying the de Casteljau algorithm it will be used the

D = E + t•(F - E)

formula for the point D that divides the EF segment in a t/(1-t) ratio. With the notations on the applet below, the computation follows:

with the final result of:

P = P1 + 3•t•(C1 - P1) + 3•t2•(C2 - 2•C1 + P1) + t3•(P2 - 3•C2 + 3•C1 - P1)        (2)

leading to the following expressions for the first and second derivatives:

P' =3•(C1 - P1) + 6•t•(C2 - 2•C1 + P1) + 3•t2•(P2 - 3•C2 + 3•C1 - P1) and

P" = 6•(C2 - 2•C1 + P1) + 6•t•(P2 - 3•C2 + 3•C1 - P1)                                                     (3)

For simplification of calculus required for solving the PX P" = 0 equation, the following notationsnote 3 will be made:

a = C1 - P1

b = C2 - 2•C1 + P1 = C2 - C1 - a                                                                                                  (4)

c = P2 - 3•C2 + 3•C1 - P1 = P2 - C2 - a -2•b

With these notations, one may put the expression of derivatives under the form:

P' =3•(a + 2•bt + ct2) and

P" = 6•(b + ct)                                                                                                                                  (5)

With this, the equation (1) becomes:

(ax + 2•bxt + cxt2)•(by + cyt) - (ay + 2•byt + cyt2)•(bx + cxt) = 0

After some more straight forward calculations, the equation to be solved for getting the position of the inflections points of a cubic Bezier is:

ax•by - ay•bx + t•(ax•cy - ay•cx) + t2•(bx•cy - by•cx) = 0                                            (6)note 4

Because only the inflection points that lay on the cubic Bezier segment are to be found, any solution of the above equation is considered only if it falls in the (0, 1) interval (excluding the interval ends). Afterwards, the correspondent position for the inflection points (if any) can be obtained either:

 

Since the equation (6) is quadratic, it can have at most 2 solutions.

Thus, a cubic Bezier segment may have at most two inflection points.

The applet on the left depicts the following configurations:


Endnotes:
  1. Note: for planar curves, one should consider the zeroes of the signed curvature expression: (P'(tX P"(t))/|P'(t)|3 for studying the location of the inflection points . In this case, one should note that in points where the first derivative becomes null (the velocity of movement on the trajectory vanishes), the curvature is not well defined: for the general case, the curve behaviour is governed by the direction and value of its second derivative (acceleration) in this kind of points. A non-degenerated (i.e. curves with one control point that is coincident with its correspondent anchor point) cubic Bezier curve will display a cusp in this location, like in the example shown in the 4th configuration on the first applet. It should mean that, for non-degenerated cubic Bezier curves, the points where the first derivative is null are also inflection points. But this is a statement I'm not willing to demonstrate right now, nor even check its truthfulness.
  2. Note: To be more mathematical exact, the parametric curve must be of C2 class: that means that all the curve and its derivatives up to the second one must be continuous. But no worries: a cubic Bezier curve falls in this categories of curves.
  3. Note: these notations would also minimize the number of multiplication required in the implementation of the algorithm.
  4. Note: for the readers that don't recalls how to solve a quadratic equation, here's a hint:

    the equation a + 2•bt + ct2 = 0 has the solutions given by
    t1 = (- b - sqrt(dis))/(2*a) and
    t2 = (- b + sqrt(dis))/(2*a)
    where:

    • dis = b2 - 4•ac - the discriminant of quadratic eq
    • sqrt - stands for square-root
    Of course, the sign of the det and the (non-zero) value for a (the coefficient of the quadratic term) must be considered.

 

 


The content of this site is copyrighted by Adrian Colomitchi. Please consult the copyright notice before doing anything except reading/browsing/printing pages of this site.