package graphics; public class BezierCurve { protected Spline spline; protected double[] G; //characteristic matrix protected final static double[][] charMatrixData = { {-1, 3, -3, 1}, { 3, -6, 3, 0}, {-3, 3, 0, 0}, { 1, 0, 0, 0} }; protected final static Matrix3D charMatrix = new Matrix3D(charMatrixData); public BezierCurve(double p1, double p2, double p3, double p4) { double[] C = new double[4]; //a,b,c,d G = new double[4]; //ctrl points G[0] = p1; G[1] = p2; G[2] = p3; G[3] = p4; charMatrix.transform(G, C); //System.err.println(C[0] +" "+ C[1] +" "+ C[2] +" "+ C[3]); spline = new Spline(C[0], C[1], C[2], C[3]); } public double get(double t) { return spline.get(t); } public Spline getSpline() { return spline; } public void dump() { System.err.println("Dumping spline points:"); System.err.println("("+ G[0] +", "+ G[1] +", "+ G[2] +", "+ G[3] +")"); } }