¡@

Bezier Curves

Download Maple Worksheet

The Bezier Curves  are used in computer-aided design and are named after a mathematician working in the automotive industry.

A cubic Bezier curve is determined by four control points   P[0](x[0],y[0]) , P[1](x[1],y[1]) , P[2](x[2],y[2]) , and   P[3](x[3],y[3]) , and is defined by the parametric equations

x = x[0]*(1-t)^3+3*x[1]*t*(1-t)^2+3*x[2]*t^2*(1-t)+x[3]*t^3 y = y[0]*(1-t)^3+3*y[1]*t*(1-t)^2+3*y[2]*t^2*(1-t)+y[3]*t^3

where   t  is in [0, 1].

Notice that when t = 0  we have (x, y) = (x[0], y[0])  and when t = 1  we have (x, y) = (x[3], y[3]) , so the curve starts at P[0]  and ends at P[3]  .

Here we graph the Bezier curve with control points P[0](4,1) , P[1](28,48) , P[2](50,42) , and P[3](40,5) .

A procedure to graph Bezier curves :

>

with(plots):

>

x[0]:=4: y[0]:=1:

>

x[1]:=28: y[1]:=48:

>

x[2]:=50: y[2]:=42:

>

x[3]:=40: y[3]:=5:

>

f:=t->x[0]*(1-t)^3+3*x[1]*t*(1-t)^2+3*x[2]*t^2*(1-t)+x[3]*t^3;

>

g:=t->y[0]*(1-t)^3+3*y[1]*t*(1-t)^2+3*y[2]*t^2*(1-t)+y[3]*t^3;

f := proc (t) options operator, arrow; x[0]*(1-t)^3+3*x[1]*t*(1-t)^2+3*x[2]*t^2*(1-t)+x[3]*t^3 end proc

g := proc (t) options operator, arrow; y[0]*(1-t)^3+3*y[1]*t*(1-t)^2+3*y[2]*t^2*(1-t)+y[3]*t^3 end proc

>    G:=plot([f(t),g(t),t=0..1],thickness=2):
t0:=textplot([8,1,`P[0]`],align=ABOVE):
t1:=textplot([29,48,`P[1]`],align=RIGHT):
t2:=textplot([51,42,`P[2]`],align=RIGHT):
t3:=textplot([44,6,`P[3]`],align=ABOVE):
pp:=pointplot({[4,1],[28,48],[50,42],[40,5]},symbol=circle,color=navy):

>

display(G,t0,t1,t2,t3,pp);

[Maple Plot]

¡@

 

Then on the same screen, graph the line segments P[0] P[1] , P[1] P[2] , and P[2] P[3] . Notice that the middle control points P[1]  and P[2]  do not lie on the curve; the curve starts at P[0]  heads toward P[1]  and P[2]  without reaching them, and ends at P[3] .

¡@

A procedure to graph Bezier curves with line segments connecting control points:

>    with(plottools):

>    Bezier:=proc(x0,y0,x1,y1,x2,y2,x3,y3)
local f,g,c,l1,l2,l3,p0,p1,p2,p3;
f:=t->x0*(1-t)^3+3*x1*t*(1-t)^2+3*x2*t^2*(1-t)+x3*t^3:
g:=t->y0*(1-t)^3+3*y1*t*(1-t)^2+3*y2*t^2*(1-t)+y3*t^3:
c:=plot([f(t),g(t),t=0..1],thickness=2,scaling=constrained, axes=none):
display(c);
end:

Warning, the name arrow has been redefined

>    Bezier_L:=proc(x0,y0,x1,y1,x2,y2,x3,y3)
local f,g,c,l1,l2,l3,p0,p1,p2,p3;
f:=t->x0*(1-t)^3+3*x1*t*(1-t)^2+3*x2*t^2*(1-t)+x3*t^3:
g:=t->y0*(1-t)^3+3*y1*t*(1-t)^2+3*y2*t^2*(1-t)+y3*t^3:
c:=plot([f(t),g(t),t=0..1],thickness=2,scaling=constrained):
l1:=line([x0,y0], [x1,y1], color=blue):
l2:=line([x1,y1], [x2,y2], color=blue):
l3:=line([x2,y2], [x3,y3], color=blue):
p0:=pointplot([x0,y0],symbol=circle,color=black):
p1:=pointplot([x1,y1],symbol=circle,color=black):
p2:=pointplot([x2,y2],symbol=circle,color=black):
p3:=pointplot([x3,y3],symbol=circle,color=black):
display(c,l1,l2,l3,p1,p2,p3,p0);
end:

> x0:=4:   y0:=1:

> x1:=28:  y1:=48:

> x2:=50:  y2:=42:

> x3:=40:  y3:=5:

> Bezier_L(x0,y0,x1,y1,x2,y2,x3,y3);

[Maple Plot]

¡@

¡@

From the graph above, it appears that the tangent at P[0]  passes through   P[1]  and the tangent at P[3]  passes through P[2] .

To produce a Bezier curve with a loop, we can change the second control point P[1] .

> display(seq(Bezier_L(x0,y0,28+5*n,48-4.3*n,x2,y2,x3,y3),n=0..10),insequence=true);

 [Maple Plot]
 

¡@

Some laser printer use Bezier curves to represent letters and other symbols.  A reasonable representation of the letter C can be done as follows:

x0:=35.5:   y0:=22:

> x1:=28:  y1:=30:

> x2:=25:  y2:=10:

> x3:=36:  y3:=17:
> Bezier(x0,y0,x1,y1,x2,y2,x3,y3);

[Maple Plot]

More complicated shapes can be represented by piecing together two or more Bezier curves. Suppose the first Bezier curve has control points P[0] , P[1] , P[2] , P[3]  and the second one has control points P[3] , P[4] , P[5] , P[6] . If we want these two pieces to join together smoothly, then the tangents at   P[3]  should match and so the points P[2]  , P[3]  and P[4]  all have to lie on this common tangent line. We can use this principle to find control points for a pair of Bezier curves that represent the letter S.

> b1:=Bezier(x0,y0,x1,y1,x2,y2,x3,y3):

> b2:=Bezier(x3,y3,x4,y4,x5,y5,x6,y6):

> display(b1,b2);

[Maple Plot]


Download Maple Worksheet