Class Bezier


  • public class Bezier
    extends java.lang.Object
    http://mathworld.wolfram.com/BezierCurve.html
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) double[] coord  
      (package private) double length  
    • Constructor Summary

      Constructors 
      Constructor Description
      Bezier​(double sx, double sy, double[] coords, int numCoords)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private double bernstein​(int numKnots, int knotNo, double param)
      Calculates the bernstein polynomial for evaluating parametric bezier
      private void calcLength()  
      private int choose​(int num, int denom)  
      java.awt.geom.Point2D.Double eval​(double param, java.awt.geom.Point2D.Double point)  
      java.awt.geom.Point2D.Double getFinalPoint​(java.awt.geom.Point2D.Double point)  
      double getLength()
      Retuns aproximation of the length of the bezier
      private double lineLength​(double x1, double y1, double x2, double y2)  
      void setCoords​(double sx, double sy, double[] coords, int numCoords)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • length

        double length
      • coord

        double[] coord
    • Constructor Detail

      • Bezier

        public Bezier​(double sx,
                      double sy,
                      double[] coords,
                      int numCoords)
    • Method Detail

      • setCoords

        public void setCoords​(double sx,
                              double sy,
                              double[] coords,
                              int numCoords)
      • getLength

        public double getLength()
        Retuns aproximation of the length of the bezier
      • calcLength

        private void calcLength()
      • lineLength

        private double lineLength​(double x1,
                                  double y1,
                                  double x2,
                                  double y2)
      • getFinalPoint

        public java.awt.geom.Point2D.Double getFinalPoint​(java.awt.geom.Point2D.Double point)
      • eval

        public java.awt.geom.Point2D.Double eval​(double param,
                                                 java.awt.geom.Point2D.Double point)
      • bernstein

        private double bernstein​(int numKnots,
                                 int knotNo,
                                 double param)
        Calculates the bernstein polynomial for evaluating parametric bezier
        Parameters:
        numKnots - - one less than number of knots in this curve hull
        knotNo - - knot we are evaluating Bernstein for
        param - - Parametric value we are evaluating at
      • choose

        private int choose​(int num,
                           int denom)