- Problem #1, pg. 705:
- Start by defining the points Pi, i=0,1,2,3, by typing:
> x0 := 4;
> y0 := 1;
etc...
- Define x(t) and y(t):
> x := t-> x0*(1-t)^3 + 3*x1*t*(1-t)^2 + ...;
> y := t-> y0*(1-t)^3 + 3*y1*t*(1-t)^2 + ...;
- To plot, use:
> with(plots):
> plot([x(t), y(t), t=0..1], options);
replacing options acording to what you want the graph to look like (e.g., color, axis, etc.).
You may want to try different ranges of t (including negative values) to see what the curve looks like, but for the final answer, you only need t=0..1.
- To plot the line segments PiPi+1, you can define parametric equations for these by writing:
> lsx0 := t -> (1-t)*x0 + t*x1;
> lsy0 := t -> (1-t)*y0 + t*y1;
for the first line segment, and similar expressions for the other two. They describe the desired line segments in the interval t=0..1 (this is something that, coincidentally, we'll cover tomorrow in class).
Use the plot command with multiple arguments to generate a graph with the Bézier Curve and the four line segments "bordering" it:
> plot({[x(t), y(t), t=0..1],[lsx0(t), lsy0(t), t=0..1],[lsx1(t), lsy1(t), t=0..1],[lsx2(t), lsy2(t), t=0..1]}, options);
You don't need to specify any options to get the plot, but using thickness=2 may help when printing.
- Problem #4, pg. 705:
The graph from problem #1 should give you a clue as to how to "draw the letter C": Choose four points in the plane that describe a box similar to the one in problem #1, but open to the right (i.e., choose the point P0 as the lower right point and then move clockwise to choose the other three). Try the Bézier Curve defined earlier with the new control points.