Package snap.geom
Class Segment
java.lang.Object
snap.geom.Shape
snap.geom.Segment
A Segment is a Shape subclass that represents a part of a path: line, quadratic, cubic.
-
Field Summary
Fields inherited from class snap.geom.Shape
_bounds, WIND_EVEN_ODD, WIND_NON_ZERO
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsSeg
(Segment aSeg) Override to return false (segment can never contain another segment (well, I suppose a weird Cubic could)).abstract Segment
Creates and returns the reverse of this segement.boolean
crossesSeg
(Segment aSeg) Returns whether this segment intersects given segment.static final boolean
equals
(double v1, double v2) Returns whether double values are equal to nearest tenth of pixel.double
Returns the length of this segment.protected abstract double
Calculates and returns length of this segment.double[]
getEndCoords
(double[] coords) Returns the point coords.Returns the hit for given segment.double
getHitPoint
(Segment aSeg) Returns the hit for given segment.double
getPointAndAngle
(double t, Point aPoint) Like getPoint(), but also returns angle of tangent at point t (in degrees).Point[]
Returns the points.abstract double
getX
(double aLoc) Returns the x value at given parametric location.double
getX0()
Returns the first point x.double
getX1()
Returns the second point x.abstract double
getY
(double aLoc) Returns the y value at given parametric location.double
getY0()
Returns the first point y.double
getY1()
Returns the second point y.boolean
intersectsSeg
(Segment aSeg) Returns whether this segment intersects given segment.abstract boolean
Returns whether segement is equal to another, regardless of direction.static Segment
newSegmentForSegAndPoints
(Seg aSeg, double[] coords) Creates a Segment for given Seg and points.abstract Segment
split
(double aLoc) Splits the segement at given parametric location and return the remainder.Methods inherited from class snap.geom.Shape
addShapes, contains, contains, contains, contains, copyFor, copyFor, copyForBounds, getBounds, getBoundsImpl, getCrossings, getDistance, getFlattenedShape, getFlattenedShape, getHeight, getNotSelfIntersectingShape, getPathIter, getSvgString, getWidth, getX, getY, intersectShapes, intersectsShape, intersectsShape, intersectsXY, isClosed, isFlat, isMultiCycle, isSelfIntersecting, isSingleCycle, shapeChanged, subtractShapes, toString
-
Field Details
-
x0
public double x0 -
y0
public double y0 -
x1
public double x1 -
y1
public double y1
-
-
Constructor Details
-
Segment
public Segment()
-
-
Method Details
-
getX0
public double getX0()Returns the first point x. -
getY0
public double getY0()Returns the first point y. -
getX1
public double getX1()Returns the second point x. -
getY1
public double getY1()Returns the second point y. -
getPoints
Returns the points. -
getEndCoords
public double[] getEndCoords(double[] coords) Returns the point coords. -
getX
public abstract double getX(double aLoc) Returns the x value at given parametric location. -
getY
public abstract double getY(double aLoc) Returns the y value at given parametric location. -
getArcLength
public double getArcLength()Returns the length of this segment.- Overrides:
getArcLength
in classShape
-
getArcLengthImpl
protected abstract double getArcLengthImpl()Calculates and returns length of this segment. -
split
Splits the segement at given parametric location and return the remainder. -
createReverse
Creates and returns the reverse of this segement. -
matches
Returns whether segement is equal to another, regardless of direction. -
containsSeg
Override to return false (segment can never contain another segment (well, I suppose a weird Cubic could)).- Overrides:
containsSeg
in classShape
-
intersectsSeg
Returns whether this segment intersects given segment.- Overrides:
intersectsSeg
in classShape
-
crossesSeg
Returns whether this segment intersects given segment.- Overrides:
crossesSeg
in classShape
-
getHit
Returns the hit for given segment. -
getHitPoint
Returns the hit for given segment. -
getPointAndAngle
Like getPoint(), but also returns angle of tangent at point t (in degrees). calculated point along curve is stored in aPoint -
equals
public static final boolean equals(double v1, double v2) Returns whether double values are equal to nearest tenth of pixel. -
newSegmentForSegAndPoints
Creates a Segment for given Seg and points.
-