Package snap.geom
Class Cubic
java.lang.Object
snap.geom.Shape
snap.geom.Segment
snap.geom.Cubic
A Segment representing a Cubic curve.
-
Field Summary
Fields inherited from class snap.geom.Shape
_bounds, WIND_EVEN_ODD, WIND_NON_ZERO
-
Constructor Summary
ConstructorDescriptionCubic
(double aX0, double aY0, double aXC0, double aYC0, double aXC1, double aYC1, double aX1, double aY1) Creates a new Cubic. -
Method Summary
Modifier and TypeMethodDescriptionCreates and returns the reverse of this segement.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.boolean
Standard equals implementation.protected double
Calculates and returns length of this segment.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.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.protected Rect
Returns the bounds.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.double[]
getEndCoords
(double[] coords) Returns the point coords.Returns the hit for given segment.getPathIter
(Transform aT) Returns a path iterator.Point[]
Returns the points.double
getX
(double aLoc) Returns the x value at given parametric location.double
getY
(double aLoc) Returns the y value at given parametric location.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.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.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.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.boolean
Returns whether cubic is equal to another, regardless of direction.void
setPoints
(double aX0, double aY0, double aXC0, double aYC0, double aXC1, double aYC1, double aX1, double aY1) Sets the quad points.split
(double aLoc) Splits this Cubic at given parametric location and return the remainder.Methods inherited from class snap.geom.Segment
containsSeg, crossesSeg, equals, getArcLength, getHitPoint, getPointAndAngle, getX0, getX1, getY0, getY1, intersectsSeg, newSegmentForSegAndPoints
Methods inherited from class snap.geom.Shape
addShapes, contains, contains, contains, contains, copyFor, copyFor, copyForBounds, getBounds, getCrossings, getDistance, getFlattenedShape, getFlattenedShape, getHeight, getNotSelfIntersectingShape, getSvgString, getWidth, getX, getY, intersectShapes, intersectsShape, intersectsShape, intersectsXY, isClosed, isFlat, isMultiCycle, isSelfIntersecting, isSingleCycle, shapeChanged, subtractShapes, toString
-
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
Returns the points. -
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 classSegment
-
getArcLengthImpl
protected double getArcLengthImpl()Calculates and returns length of this segment.- Specified by:
getArcLengthImpl
in classSegment
-
getBoundsImpl
Returns the bounds.- Overrides:
getBoundsImpl
in classShape
-
getPathIter
Returns a path iterator.- Specified by:
getPathIter
in classShape
-
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. -
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. -
split
Splits this Cubic at given parametric location and return the remainder. -
createReverse
Creates and returns the reverse of this segement.- Specified by:
createReverse
in classSegment
-
equals
Standard equals implementation. -
matches
Returns whether cubic is equal to another, regardless of direction. -
getHit
Returns the hit for given 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.
-