Package snap.geom

Class Cubic


public class Cubic extends Segment
A Segment representing a Cubic curve.
  • Field Details

    • cp0x

      public double cp0x
    • cp0y

      public double cp0y
    • cp1x

      public double cp1x
    • cp1y

      public double cp1y
  • Constructor Details

    • Cubic

      public Cubic(double aX0, double aY0, double aXC0, double aYC0, double aXC1, double aYC1, double aX1, double aY1)
      Creates a new Cubic.
  • Method Details

    • getPoints

      public Point[] getPoints()
      Returns the points.
      Overrides:
      getPoints in class Segment
    • setPoints

      public void setPoints(double aX0, double aY0, double aXC0, double aYC0, double aXC1, double aYC1, double aX1, double aY1)
      Sets the quad points.
    • getEndCoords

      public double[] getEndCoords(double[] coords)
      Returns the point coords.
      Overrides:
      getEndCoords in class Segment
    • getArcLengthImpl

      protected double getArcLengthImpl()
      Calculates and returns length of this segment.
      Specified by:
      getArcLengthImpl in class Segment
    • getBoundsImpl

      protected Rect getBoundsImpl()
      Returns the bounds.
      Overrides:
      getBoundsImpl in class Shape
    • getPathIter

      public PathIter getPathIter(Transform aT)
      Returns a path iterator.
      Specified by:
      getPathIter in class Shape
    • getX

      public double getX(double aLoc)
      Returns the x value at given parametric location. p' = (1-t)^3*p0 + 3*t*(1-t)^2*p1 + 3*t^2*(1-t)*p2 + t^3*p3.
      Specified by:
      getX in class Segment
    • getY

      public double getY(double aLoc)
      Returns the y value at given parametric location. p' = (1-t)^3*p0 + 3*t*(1-t)^2*p1 + 3*t^2*(1-t)*p2 + t^3*p3.
      Specified by:
      getY in class Segment
    • split

      public Cubic split(double aLoc)
      Splits this Cubic at given parametric location and return the remainder.
      Specified by:
      split in class Segment
    • createReverse

      public Cubic createReverse()
      Creates and returns the reverse of this segement.
      Specified by:
      createReverse in class Segment
    • equals

      public boolean equals(Object anObj)
      Standard equals implementation.
      Overrides:
      equals in class Object
    • matches

      public boolean matches(Object anObj)
      Returns whether cubic is equal to another, regardless of direction.
      Specified by:
      matches in class Segment
    • getHit

      public SegHit getHit(Segment aSeg)
      Returns the hit for given segment.
      Overrides:
      getHit in class Segment
    • getBounds

      public static Rect getBounds(double x0, double y0, double xc0, double yc0, double xc1, double yc1, double x1, double y1, Rect aRect)
      Returns the bounds for given quad points.
    • getBounds2

      public static Rect getBounds2(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, Rect aRect)
      Returns the bounds of the bezier.
    • getDistanceSquared

      public static double getDistanceSquared(double x0, double y0, double xc0, double yc0, double xc1, double yc1, double x1, double y1, double aX, double aY)
      Returns whether Cubic for given points is intersected by line with given points.
    • crossings

      public static int crossings(double x0, double y0, double xc0, double yc0, double xc1, double yc1, double x1, double y1, double px, double py, int level)
      Returns the number of crossings for the ray from given point extending to the right.
    • isLine

      public static boolean isLine(double x0, double y0, double xc0, double yc0, double xc1, double yc1, double x1, double y1)
      Returns whether Cubic for given points is effectively a line.
    • intersectsLine

      public static boolean intersectsLine(double x0, double y0, double xc0, double yc0, double xc1, double yc1, double x1, double y1, double px0, double py0, double px1, double py1)
      Returns whether Cubic for given points is intersected by line with given points.
    • intersectsQuad

      public static boolean intersectsQuad(double x0, double y0, double xc0, double yc0, double xc1, double yc1, double x1, double y1, double px0, double py0, double pxc0, double pyc0, double px1, double py1)
      Returns whether Cubic for given points is intersected by line with given points.
    • intersectsCubic

      public static boolean intersectsCubic(double x0, double y0, double xc0, double yc0, double xc1, double yc1, double x1, double y1, double px0, double py0, double pxc0, double pyc0, double pxc1, double pyc1, double px1, double py1)
      Returns whether Cubic for given points is intersected by Quad with given points.