Parametric Curves

Bezier Curves

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:

> 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]

¡@

BACK

¡@