Interface Segment2D
-
-
Method Summary
Modifier and Type Method Description Line2D<P>
toLine()
abstract Segment2D<P>
copyWith(P first, P second)
Creates a copy of this Segment2D using the specified first and second points. Boolean
contains(P point)
Checks if the segment contains a point. P
closestPointTo(P point)
Finds the point of the segment which is closest to the provided point. Double
distanceTo(P point)
Computes the shortest distance between the segment and the given point. Double
distanceTo(Segment2D<P> other)
Computes the shortest distance between two segments (= the shortest distance between any two of their points). Boolean
isParallelTo(Segment2D<P> other)
Checks if two segments are parallel. Boolean
isCollinearWith(P point)
Checks if first, second and point lie on a single line. Boolean
isCollinearWith(Segment2D<P> other)
Checks if two segments lie on a single line. Boolean
overlapsWith(Segment2D<P> other)
Checks if two segments overlap (= are collinear and share one or more points). Intersection2D<P>
intersect(Segment2D<P> other)
Intersects two segments. Intersection2D<P>
intersectCircle(P center, Double radius)
Intersects a segment and a circle. Segment2D<P>
shrunk(Double factor)
Boolean
isInRectangle(Vector2D<?> origin, Double width, Double height)
Checks if this segment is inside a rectangular region described by an origin, width and height (must be positive). ClosedRange<Double>
toRange(Boolean getXCoords)
Maps the segment a ClosedRange, this is done by extracting either the X coordinates or the Y coordinates of the two endpoints of the segment. abstract P
getFirst()
The first endpoint of the segment. abstract P
getSecond()
The second endpoint of the segment. Double
getLength()
Boolean
isDegenerate()
Boolean
isHorizontal()
Boolean
isVertical()
P
getMidPoint()
P
getToVector()
-
-
Method Detail
-
closestPointTo
P closestPointTo(P point)
Finds the point of the segment which is closest to the provided point.
-
distanceTo
Double distanceTo(P point)
Computes the shortest distance between the segment and the given point.
-
distanceTo
Double distanceTo(Segment2D<P> other)
Computes the shortest distance between two segments (= the shortest distance between any two of their points).
-
isParallelTo
Boolean isParallelTo(Segment2D<P> other)
Checks if two segments are parallel. Throws an UnsupportedOperationException if any of the two segment isDegenerate.
-
isCollinearWith
Boolean isCollinearWith(P point)
-
isCollinearWith
Boolean isCollinearWith(Segment2D<P> other)
Checks if two segments lie on a single line.
-
overlapsWith
Boolean overlapsWith(Segment2D<P> other)
Checks if two segments overlap (= are collinear and share one or more points).
-
intersect
Intersection2D<P> intersect(Segment2D<P> other)
Intersects two segments.
-
intersectCircle
Intersection2D<P> intersectCircle(P center, Double radius)
Intersects a segment and a circle.
-
isInRectangle
Boolean isInRectangle(Vector2D<?> origin, Double width, Double height)
Checks if this segment is inside a rectangular region described by an origin, width and height (must be positive).
-
toRange
ClosedRange<Double> toRange(Boolean getXCoords)
Maps the segment a ClosedRange, this is done by extracting either the X coordinates or the Y coordinates of the two endpoints of the segment. getXCoords indicates which pair of coordinates should be extracted (defaults to isHorizontal). This can be useful e.g. to represent portions of axis-aligned segments without creating new ones.
-
isDegenerate
Boolean isDegenerate()
-
isHorizontal
Boolean isHorizontal()
-
isVertical
Boolean isVertical()
-
getMidPoint
P getMidPoint()
-
getToVector
P getToVector()
-
-
-
-