Sep. 2004, Author: Adrian Colomitchi
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.
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:
(P_{x}, P_{y}) = (f_{x}(t), f_{y}(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'(t) X
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'(t) X
P"(t)
= f'_{x}(t)•f"_{y}(t) - f'_{y}(t)•f"_{x}(t)
Demonstrating of the above statement is possible^{note
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 smoothly^{note
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:
X
P"(t) = f'_{x}(t)•f"_{y}(t) - f'_{y}(t)•f"_{x}(t) = 0
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:
As noted above, one should compute the solution of the
P'(t) X
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:
M = A + t•(B - A) =
= P_{1} + 2•t•(C_{1}
- P_{1}) + t^{2}•(C_{2}
- 2•C_{1} + P_{1})
N = B + t•(C - B) =
= C_{1} + 2•t•(C_{2}
- C_{1}) + t^{2}•(P_{2}
- 2•C_{2} + C_{1})
after step
3, the coordinates of the P point will be:
P = M + t•(N - M)
with the final result of:
P = P_{1} + 3•t•(C_{1} - P_{1}) + 3•t^{2}•(C_{2} - 2•C_{1} + P_{1}) + t^{3}•(P_{2} - 3•C_{2} + 3•C_{1} - P_{1}) (2)
leading to the following expressions for the first and second derivatives:
P' =3•(C_{1} - P_{1}) + 6•t•(C_{2} - 2•C_{1} + P_{1}) + 3•t^{2}•(P_{2} - 3•C_{2} + 3•C_{1} - P_{1}) and
P" = 6•(C_{2} - 2•C_{1} + P_{1}) + 6•t•(P_{2} - 3•C_{2} + 3•C_{1} - P_{1}) (3)
For simplification of calculus required for solving the P' X
P" = 0
equation, the following notations^{note
3} will be made:
b = C_{2} - 2•C_{1} + P_{1} = C_{2} - C_{1} - a (4)
c = P_{2} - 3•C_{2} + 3•C_{1} - P_{1} = P_{2} - C_{2} - a -2•b
With these notations, one may put the expression of derivatives under the form:
P' =3•(a + 2•b•t + c•t^{2}) and
P" = 6•(b + c•t) (5)
With this, the equation (1) becomes:
(a_{x} + 2•b_{x}•t
+ c_{x}•t^{2})•(b_{y} +
c_{y}•t) - (a_{y} + 2•b_{y}•t
+ c_{y}•t^{2})•(b_{x} +
c_{x}•t) = 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:
a_{x}•b_{y} - a_{y}•b_{x}
+ t•(a_{x}•c_{y} - a_{y}•c_{x})
+ t^{2}•(b_{x}•c_{y} - b_{y}•c_{x})
= 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:
0
, 1
).
No points of inflection - the curve keeps uniform its bending direction;0
, 1
)
range. One point of inflection - the curve change the bending direction once;0
, 1
)
range. Two points of inflection - the curve change the bending direction
twice;0
, 1
)
range - the first derivative is null in this point. A single point
of inflection - the curve displays a spike/corner.X
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.Note: for the readers that don't recalls how to solve a quadratic equation, here's a hint:
the equation a + 2•b•t
+ c•t^{2} = 0
has the solutions given by
t_{1} = (- b - sqrt(dis))/(2*a) and
t_{2} = (- b + sqrt(dis))/(2*a)
where:
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.