Class RMQuadratic

  • All Implemented Interfaces:
    java.lang.Cloneable
    Direct Known Subclasses:
    RMBezier

    public class RMQuadratic
    extends RMLine
    This class models a simple quadratic curve, providing methods for extracting points, distance calculation, bisection, hit detection and such.
    • Constructor Detail

      • RMQuadratic

        public RMQuadratic()
        Creates a new quadratic curve.
      • RMQuadratic

        public RMQuadratic​(RMPoint startPoint,
                           RMPoint controlPoint,
                           RMPoint endPoint)
        Creates a new quadratic curve for this gvein start point, control point and end point.
      • RMQuadratic

        public RMQuadratic​(double x1,
                           double y1,
                           double x2,
                           double y2,
                           double x3,
                           double y3)
        Creates a new quadratic curve for this gvein start point, control point and end point.
    • Method Detail

      • setCurve

        public void setCurve​(double x1,
                             double y1,
                             double x2,
                             double y2,
                             double x3,
                             double y3)
        Sets the curve values.
      • getPoint

        public RMPoint getPoint​(double t,
                                RMPoint aPoint)
        Returns the point on this curve at the parametric location t (defined from 0-1).
        Overrides:
        getPoint in class RMLine
      • getDistance

        public double getDistance​(RMPoint aPoint)
        Returns the minimum distance from the given point to this segment.
        Overrides:
        getDistance in class RMLine
      • getDistanceQuadratic

        public double getDistanceQuadratic​(RMPoint aPoint)
        Returns the minimum distance from the given point to the curve.
      • getPointCount

        public int getPointCount()
        Returns the point count of segment.
        Overrides:
        getPointCount in class RMLine
      • getPointX

        public double getPointX​(int anIndex)
        Returns the x of point at given index.
        Overrides:
        getPointX in class RMLine
      • getPointY

        public double getPointY​(int anIndex)
        Returns the y of point at given index.
        Overrides:
        getPointY in class RMLine
      • subdivide

        public void subdivide​(RMQuadratic left,
                              RMQuadratic right)
        Subdivides this curve into the given left and right curves.
      • getMinX

        public double getMinX()
        Returns the min x point of this bezier.
        Overrides:
        getMinX in class RMLine
      • getMinY

        public double getMinY()
        Returns the min y point of this bezier.
        Overrides:
        getMinY in class RMLine
      • getMaxX

        public double getMaxX()
        Returns the max x point of this bezier.
        Overrides:
        getMaxX in class RMLine
      • getMaxY

        public double getMaxY()
        Returns the max y point of this bezier.
        Overrides:
        getMaxY in class RMLine
      • getBounds

        public void getBounds​(java.awt.geom.Rectangle2D aRect)
        Returns the bounds.
        Overrides:
        getBounds in class RMLine
      • getBounds

        public static void getBounds​(double x0,
                                     double y0,
                                     double x1,
                                     double y1,
                                     double x2,
                                     double y2,
                                     java.awt.geom.Rectangle2D aRect)
        Returns the bounds of the bezier.
      • getArcLength

        public float getArcLength​(float start,
                                  float end)
        Returns the arc length of the segment up to parametric value t
        Overrides:
        getArcLength in class RMLine
      • getArcLengthFunction

        public RMMath.RMFunc getArcLengthFunction()
        Returns an RMFunc which calculates the arclength of the curve up to t
      • getParameterForLength

        public float getParameterForLength​(float l)
        Returns parametric point t that corresponds to a given length along the curve. l is in the range [0-1] (ie. percentage of total arclength)
        Overrides:
        getParameterForLength in class RMLine
      • getInverseArcLengthFunction

        public RMMath.RMFunc getInverseArcLengthFunction()
        Returns an RMFunc which calculates t for a percentage length along the curve.