3
$\begingroup$

I'm trying to understand quadratic Bézier curves but I cannot get pass one thing. Please, what is a "curvature" and how can I calculate it?

I'm asking because I found for instance this and this.

I also saw:
$\text{Curvature}\, = \,(P1x - P2x)(P3y - P2y) - (P3x - P2x)(P1y - P2y) $ where $P1$, $P2$, $P3$ are points defining the curve.

There is the problem, I don't see how one could arrive to such formula. Could someone explain it to me?

3 Answers 3

1

Maybe it's easier to start with "radius of curvature", rather than curvature. Let's take a specific point on our curve. Think of a circle that is touching the curve at this point, and is curving by the same amount as the curve itself. This circle has a name -- it's called the "osculating" circle, derived from the latin word for "kissing". The idea is that the circle has a very intimate form of contact with the original curve. The radius of this osculating circle is called the radius of curvature of the curve at the given point. Saying it another way, the radius of curvature at a point is the radius of a "best fit" circle at that point.

Now, if you've grasped all that, curvature is easy -- curvature is just the reciprocal of radius of curvature.

Intuitively, curvature is a measure of how fast a curve turns away from its tangent line. You can get formulas for curvature and radius of curvature in terms of the derivatives of the curve equations. That's where the formula you cited comes from. You can find these formulas in any book on "differential geometry".

For a quadratic Bezier curve, curvature depends strongly on the angle between the two "legs" of the control polygon. If these two legs are collinear (which means that the three control points are collinear) then the curve will have zero curvature everywhere. This should make sense -- the curve will become straight, so it's radius of curvature is infinite, so it's curvature is zero.

1

This formula is incomplete, it evaluates a multiple of the curvature.

Let us establish it by fitting a circle to the three points, as follows: first translate the points so that $P_2$ comes to the origin, and define $U=P_1-P_2,V=P_3-P_2$.

The equation of a circle through the origin is known to be $(x-x_C)^2+(y-y_C)^2=x_C^2+y_C^2=r^2,$which is of the form $2x_Cx+2y_Cy=x^2+y^2=w.$ So we form the system $x_Cx_U+y_Cy_U=\frac{w_U}2\\x_Cx_V+y_Cy_V=\frac{w_V}2.$ The solution is given by Cramer's rule, $\Delta=\left| \begin{array}{ccc}x_U&y_U\\ x_V&y_V\\ \end{array} \right|,\\ x_C=\frac{\left| \begin{array}{ccc}w_U&y_U\\w_V&y_V\\ \end{array} \right|}{2\Delta}, y_C=\frac{\left| \begin{array}{ccc}x_U&w_U\\x_V& w_V\\ \end{array} \right|}{2\Delta}.$ Then we deduce the approximation of the radius of curvature $r$, or its inverse $\kappa$, the curvature, and

$\kappa=\frac1{\sqrt{x_C^2+y_C^2}}=2\frac{x_Uy_V-x_Vy_U}{\sqrt{(w_Ux_V-w_Vx_U)^2+(w_Uy_V-w_Vy_U)^2}}.$

In the numerator, you recognize the original expression.

0

The curvature for a parameterized curve $B(t) = ((x(t), y(t))$ is given by [1]

$$ \kappa(t) = \frac{\left|B'(t), B''(t)\right|}{|| B'(t)||^3}, $$

(Edit: fixed power in the denominator.)

where the numerator is the determinant of the matrix formed by concatenating $B'(t)$ and $B''(t)$.

Note that the curvature is a function of the parameter $t$, the curvature is not necessarily constant over the curve.

A quadratic Bezier curve is defined by the points $P_0$, $P_1$ and $P_2$ is parameterized by [2]

$ B(t) = \left(1 - t\right)\left[\left(1 - t\right) P_0 + P_1\right] + t \left[ \left(1 - t\right) P_1 + t P_2 \right], $

with derivatives

$ B'(t) = 2\left(1 - t\right)\left(P_1 - P_0\right) + 2t\left(P_2 - P_1\right) $ and $ B''(t) = 2\left(P_2 - 2P_1 + P_0\right). $

Substituting these into the expression for the curvature (using the bilinearity of the determinant operator and the fact that $\left|x,x\right|\equiv0$) yields the numerator

$\begin{align} n(t) &= \left|B'(t), B''(t)\right| \\ &= 4(1-t)\left|P_1-P_0, P_0 - 2P_1 + P_2\right| \\ &\quad+ 4t\left|P_2-P_1, P_0 - 2P_1 + P_2\right| \\ &= 4(1-t)\left|P_1-P_0, P_2-P_1\right| + 4t\left|P_2-P_1, P_0-P_1\right| \\ &= 4\left| P_1-P_0, P_2-P_1 \right|. \end{align}$

The denominator is given by

$ m(t) = ||B(t)||^3, $

with

$\begin{align} ||B(t)||^2 &= 4(1-t)^2 ||P_1 - P_0||^2 + 8t(1-t)(P_1 - P_0)\cdot(P_2 - P_1) + 4t^2||P_2 - P_1||^2. \end{align}$

As I originally came here in search for maximum curvature of a quadratic Bezier curve, I will also present that here, even if it is not strictly in the question.

The maximum curvature is found at either (i) the maximum of the function $\kappa(t)$ or (ii) one of the endpoints of the curve if the maximum lies outside the range $(0,1)$.

The maximum of the function $\kappa(t)$ corresponds to $\kappa'(t) = 0$, i.e.

$ \kappa'(t) = \frac{n'(t) m(t) - n(t) m'(t)}{m(t)^2}. $

Given that the numerator $m(t)$ is a constant, finding zeros of $\kappa'(t)$ equates to finding zeros of $m'(t)$, which in turn reduces to finding zeros of $||B'(t)||^2$. This is given by

$ \frac{\mathrm{d}}{\mathrm{d}t} ||B(t)||^2 = 8(P_1 - P_0) \cdot (P_0 - 2P_1 + P_2) + 8t || P_0 - 2P_1 + P_2 ||, $

which gives us the optimal parameter value

$ t^* = \frac{(P_1 - P_0) \cdot (P_0 - 2P_1 + P_2)}{|| P_0 - 2P_1 + P_2 ||}. $

Substituting this in the expression and some more algebra yields

$ \kappa(t^*) = \frac{||P_2 - 2P_1 + P_0||}{2|P_1 - P_0, P_2 - P_1|}. $

Hope this helps (someone, somewhere, somewhat, someday)

[1] https://en.wikipedia.org/wiki/Curvature

[2] https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Quadratic_B%C3%A9zier_curves