2.1 Implementing the de Casteljau algorithm
Given a set of n points, we want to implement
the de Casteljau algorithm. You are asked to
 write a class Bezier which extends
class Curve.
 implement method Point_2 evaluate(double t)
which computes the point b(t).
 implement method plotCurve(double dt)
which draw the curve in the frame, by evaluating the
curve with a given step.
 implement method Point_2
recursiveDeCasteljau(int r, int i, double t)
which computes the ith Bézier point (at setp r), for
value t, with the recursive definition.
 implement method Point_2
iterativeDeCasteljau(double t) which computes
the Bézier curve with the iterative scheme (in linear
space).
You can follow the code below:
public class Bezier extends Curve {
Transformation_2 transformation;
public Bezier(DrawCurve frame, LinkedList<Point_2> p) { super(frame, p); transformation=null; }
public Bezier(DrawCurve frame, LinkedList<Point_2> p, Transformation_2 transformation) { super(frame, p); this.transformation=transformation; } public Bezier(DrawCurve frame, Point_2[] points, Transformation_2 transformation) { super(frame, points); this.transformation=transformation; }
... ... ...
public Bezier[] subdivide(double t) { Point_2[] controlPolygon=this.points; int n=this.points.length1; // degree and number of edges of the control polygon
Point_2[] b0=new Point_2[n+1]; // first control polygon Point_2[] b1=new Point_2[n+1]; // second control polygon Bezier[] result=new Bezier[2]; // the pair of Bezier curves to return as result
//throw new Error("To be completed: TD3");
// store and return the pair of new control polygons result[0]=new Bezier(this.frame, b0, this.transformation); result[1]=new Bezier(this.frame, b1, this.transformation); return result; }
}
2.2 Compute Bézier curves with the efficient (nested)
evaluation
 implement method Point_2 BernsteinBezier(double
t) which computes the Bézier curve with nested
evaluation of the Bernstein form of a Bézier curve.
Remark:
What do you observe implementing and comparing these
methods?
2.3 Render a Bézier curve with the subdivision method
 implement method public Bezier[]
subdivide(double t) which subdivides the Bézier
curve into a couple of Bézier curves, with parameter t.
Modifiy the plot method of your class, in order to
visualize the corresponding control polygons of the
two curves (see the picture on the right).
 implement method public void
subdivisionRendering(int n) which renders the
Bézier curve (subdivide n times with
parameter t=0.5). Remove comments from file
DrawCurve.java in order to plot the curve
with the subdivision method.

Example: cubic Bézier curve:
(x_{0}, y_{0})
... (x_{3}, y_{3}).
A Bézier curve subdivided with parameter t=0.5
The two subcurves are drawn in red.
Example of subdivision rendering of a cubic Bézier curve
