Reputation: 6778
I need to determine points of inflection (points where the curvature changes) on a 2d Bezier curve, parameterized by t, 0 <= t <= 1, if they exist. My original method was to sample along the curve, evaluating second derivatives and finding the point where the derivative's sign changes.
2DVector curvature1, curvature2;
for (double t = 0, t <= 1.0; t += STEP) {
curvature1 = bezier.CurvatureAt(t);
curvature2 = bezier.CurvatureAt(t + (STEP/2.0 >= 1.0 ? 0 : t + STEP/2.0));
if (isNegative(curvature1) ? isPositive(curvature2) : isNegative(curvature2)) {
inflection_point = t;
}
}
where CurvatureAt() is a method that evaluates the second derivative of the bezier at t, but as the bezier curve is a vector valued function the derivative is returned as a 2D vector (not std::vector, a 2D vector class). I dont know how to interpret "where the sign changes" for vectors. Basically i dont know how to write isNegative or isPositive in the above snippet.
are there any other ways to find points of inflection on a 2d Bezier curve?
I dont think its possible to determine a closed form solution to this problem because the Bezier can be of arbitrary degree, however please correct me if I'm wrong here.
Upvotes: 1
Views: 2400
Reputation: 1264
To determine the points of inflection on a bezier, find the time or times in the interval (0, 1) [excluding the endpoints of course] for which the cross product of the first and second derivatives of the parametric equation of the bezier is zero i.e. f' X f'' = 0.
This is noted in various sources like this page and p 4 of this paper.
Upvotes: 1
Reputation: 93040
Curvature is related to but not the same as second derivative.
The signed curvature of a parametric curve P(t) = (x(t), y(t))
is actually a number and is defined as:
k(t) = (x'y'' - x''y') / (x' * x' + y' * y')^(3/2)
If you use this formula your original idea should work.
Upvotes: 2