Package snap.geom
Class Line
java.lang.Object
snap.geom.Shape
snap.geom.Segment
snap.geom.Line
A class to represent a mathematical line.
-
Field Summary
Fields inherited from class snap.geom.Shape
_bounds, WIND_EVEN_ODD, WIND_NON_ZERO
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(double aX, double aY) Returns whether shape contains x/y.boolean
contains
(double aX, double aY, double aLineWidth) Returns whether shape with line width contains point.boolean
Returns whether shape contains x/y/w/h.Returns the shape in rect.Creates and returns the reverse of this segement.static int
crossings
(double x0, double y0, double x1, double y1, double px, double py) 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
Returns the bounds for given line points.protected Rect
Returns the shape bounds.double
getDistance
(double aX, double aY) Returns the minimum distance from the given point to this line.static double
getDistance
(double x0, double y0, double x1, double y1, double aX, double aY) Returns the distance from the given line points (p1,p2) to the given point.double
getDistanceSquared
(double aX, double aY) Returns the minimum distance from the given point to this line, squared.static double
getDistanceSquared
(double x0, double y0, double x1, double y1, double aX, double aY) Returns the distance from the given line points (p1,p2) to the given point.Returns the hit for given segment.getPathIter
(Transform aTrans) Returns the path iterator.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
intersectsLine
(double x0, double y0, double x1, double y1, double px0, double py0, double px1, double py1) Returns whether line for given points is intersected by second line with given points.static boolean
isCollinear
(double x0, double y0, double x1, double y1, double x2, double y2) Returns whether given three points are collinear.boolean
Returns whether line is equal to another, regardless of direction.void
setPoints
(double aX0, double aY0, double aX1, double aY1) Sets the line points.split
(double aLoc) Splits the line at given parametric location and return the remainder.Methods inherited from class snap.geom.Segment
containsSeg, crossesSeg, equals, getArcLength, getEndCoords, getHitPoint, getPointAndAngle, getPoints, getX0, getX1, getY0, getY1, intersectsSeg, newSegmentForSegAndPoints
Methods inherited from class snap.geom.Shape
addShapes, contains, copyFor, copyForBounds, getBounds, getCrossings, getFlattenedShape, getFlattenedShape, getHeight, getNotSelfIntersectingShape, getSvgString, getWidth, getX, getY, intersectShapes, intersectsShape, intersectsShape, intersectsXY, isClosed, isFlat, isMultiCycle, isSelfIntersecting, isSingleCycle, shapeChanged, subtractShapes, toString
-
Constructor Details
-
Line
public Line(double aX0, double aY0, double aX1, double aY1) Creates a new line.
-
-
Method Details
-
setPoints
public void setPoints(double aX0, double aY0, double aX1, double aY1) Sets the line points. -
getArcLengthImpl
protected double getArcLengthImpl()Calculates and returns length of this segment.- Specified by:
getArcLengthImpl
in classSegment
-
getBoundsImpl
Returns the shape bounds.- Overrides:
getBoundsImpl
in classShape
-
copyFor
Returns the shape in rect. -
getPathIter
Returns the path iterator.- Specified by:
getPathIter
in classShape
-
contains
public boolean contains(double aX, double aY) Returns whether shape contains x/y. -
contains
Returns whether shape contains x/y/w/h. -
contains
public boolean contains(double aX, double aY, double aLineWidth) Returns whether shape with line width contains point. -
getX
public double getX(double aLoc) Returns the x value at given parametric location. -
getY
public double getY(double aLoc) Returns the y value at given parametric location. -
split
Splits the line at given parametric location and return the remainder. -
createReverse
Creates and returns the reverse of this segement.- Specified by:
createReverse
in classSegment
-
getDistance
public double getDistance(double aX, double aY) Returns the minimum distance from the given point to this line.- Overrides:
getDistance
in classShape
-
getDistanceSquared
public double getDistanceSquared(double aX, double aY) Returns the minimum distance from the given point to this line, squared. -
equals
Standard equals implementation. -
matches
Returns whether line is equal to another, regardless of direction. -
getHit
Returns the hit for given segment. -
getDistance
public static double getDistance(double x0, double y0, double x1, double y1, double aX, double aY) Returns the distance from the given line points (p1,p2) to the given point. -
getDistanceSquared
public static double getDistanceSquared(double x0, double y0, double x1, double y1, double aX, double aY) Returns the distance from the given line points (p1,p2) to the given point. -
getBounds
Returns the bounds for given line points. -
crossings
public static int crossings(double x0, double y0, double x1, double y1, double px, double py) Returns the number of crossings for the ray from given point extending to the right. -
intersectsLine
public static boolean intersectsLine(double x0, double y0, double x1, double y1, double px0, double py0, double px1, double py1) Returns whether line for given points is intersected by second line with given points. -
isCollinear
public static boolean isCollinear(double x0, double y0, double x1, double y1, double x2, double y2) Returns whether given three points are collinear.
-