> Hi all,
> I need to evaluate the area of a closed cubic bezier curve defined by
> the list of control points ( num. points = 1 + 3 * num. bezier sub-curves ).
> I found a posible solution evaluating the curve to get a polyline and
> calculate the area of the enclosed area ( very simple ) but I'd like to
> use a closed solution that doesn't depend on the number of points of the
> Any advise? Thanks..
An interesting problem. For any piecewise differentiable curve in 2D,
the following general procedure gives you the area inside the curve /
series of curves. For polynomial curves (Bezier curves), you will get
closed form solutions.
g(t) be a piecewise differentiable curve, with 0 <= t <= 1. g(t) is
oriented clockwise and g(1) = g(0).
F(x, y) = [x, y] / 2
Then div(F(x, y)) = 1
where div is for divergence.
Now the divergence theorem gives you the area inside the closed curve g
(t) as a line integral along the curve:
int(dot(F(g(t)), perp(g'(t))) dt, t = 0..1)
= (1 / 2) * int(dot(g(t), perp(g'(t))) dt, t = 0..1)
perp(x, y) = (-y, x)
where int is for integration, ' for differentiation and dot for dot
product. The integration has to be pieced to the parts corresponding to
the smooth curve segments.
Now for examples. Take the Bezier degree 3 and one such curve with
control points (x0, y0), (x1, y1), (x2, y2), (x3, y3). The integral over
this curve is:
I := 3 / 10 * y1 * x0 - 3 / 20 * y1 * x2 -
3 / 20 * y1 * x3 - 3 / 10 * y0 * x1 -
3 / 20 * y0 * x2 - 1 / 20 * y0 * x3 +
3 / 20 * y2 * x0 + 3 / 20 * y2 * x1 -
3 / 10 * y2 * x3 + 1 / 20 * y3 * x0 +
3 / 20 * y3 * x1 + 3 / 10 * y3 * x2
Calculate this for each curve in the sequence and add them up. The sum
is the area enclosed by the curves (assuming the curves form a loop).
If the curve consists of just one Bezier curve, then it must be x3 = x0
and y3 = y0, and the area is:
Area := 3 / 20 * y1 * x0 - 3 / 20 * y1 * x2 -
3 / 20 * y0 * x1 + 3 / 20 * y0 * x2 -
3 / 20 * y2 * x0 + 3 / 20 * y2 * x1
Hope I did not do mistakes.