import java.awt.*; import java.util.*; /* This should not be here for Java 1.4 import Point2D; */ public class BezierCurve284 extends BezierCurve2D { // Member Variables //////////////////////////////////////////////////////////////////////////// // CS284: These are the variable you will be dealing with // Also look at the variables in Curve2D.java // The Systolic Array is discussed in Rockwood p.46-48 // This 2D array is indexed by [j][i], where j = recursion level and i = control point Point2D[][] m_aaSystolicArray = new Point2D[m_iMaxControlPoints][m_iMaxControlPoints]; // Array of points on the curve Point2D[] m_aCurvePoints = new Point2D[m_iMaxSlices+1]; // //////////////////////////////////////////////////////////////////////////// // Member Functions public BezierCurve284(boolean bDrawSub, double t) { super(bDrawSub, t); } public void setTValue(double t) { super.setTValue(t); m_dT = t; deCasteljau(m_dT); } public void calculateCurve() { super.calculateCurve(); if( m_iControlPoints > 1 ) { /////////////////////////////////////////////////////////// // CS284: Remove the code below and add code that fills // m_aCurvePoints with the m_iSlices + 1 points that // approximate the curve. int i; double delta, ti; delta = 1.0/m_iSlices; for (i=0; i<=m_iSlices; i++) { ti = i*delta; m_aCurvePoints[i] = deCasteljau(ti); } // /////////////////////////////////////////////////////////// deCasteljau(m_dT); // calculate systolic array so we can draw // the subdivision segments } } public Point2D deCasteljau(double t) { Point2D pt; pt = new Point2D(); /////////////////////////////////////////////////////////////// // CS284: Replace the code below with code to calculate // the systolic array. The final curve point corresponding // to parameter value t should be returned. int i, j; Point2D pt1, pt2; for (i=0; i 1 ) { g.setColor(Color.blue); { ///////////////////////////////////////////////////////////////// // CS284: Replace the code below so that it draws the subdivision segments int i, j; Point2D pt1, pt2; for (j=1; j