-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classSegment2D.Companion
-
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. Booleancontains(P point)Checks if the segment contains a point. PclosestPointTo(P point)Finds the point of the segment which is closest to the provided point. DoubledistanceTo(P point)Computes the shortest distance between the segment and the given point. DoubledistanceTo(Segment2D<P> other)Computes the shortest distance between two segments (= the shortest distance between any two of their points). BooleanisParallelTo(Segment2D<P> other)Checks if two segments are parallel. BooleanisCollinearWith(P point)Checks if first, second and point lie on a single line. BooleanisCollinearWith(Segment2D<P> other)Checks if two segments lie on a single line. BooleanoverlapsWith(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)BooleanisInRectangle(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 PgetFirst()The first endpoint of the segment. abstract PgetSecond()The second endpoint of the segment. DoublegetLength()BooleangetIsDegenerate()BooleangetIsHorizontal()BooleangetIsVertical()PgetMidPoint()PgetToVector()-
-
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)
-
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.
-
getIsDegenerate
Boolean getIsDegenerate()
-
getIsHorizontal
Boolean getIsHorizontal()
-
getIsVertical
Boolean getIsVertical()
-
getMidPoint
P getMidPoint()
-
getToVector
P getToVector()
-
-
-
-