Package com.solibri.geometry.primitive2d
Interface Segment2d
- All Known Subinterfaces:
MSegment2d
public interface Segment2d
Read-only interface for handling segments in the XY-plane.
- Since:
- 9.10.2
-
Method Summary
Modifier and TypeMethodDescriptionclosestPointTo
(Vector2d point) Returns the point on this segment that is closest to the given point in the XY-plane.boolean
Returns true if the given point lies on this segment in the XY-plane, otherwise returns false.static Segment2d
Creates an new instance.double
Returns the minimum distance between this segment and the point in the XY-plane.double
Returns the minimum distance in the XY-plane between this and the given segment.double
distanceSquared
(Vector2d point) Returns the square of the minimum distance between this segment and the point in the XY-plane.double
distanceSquared
(Segment2d other) Returns the square of the minimum distance in the XY-plane between this and the given segment.default boolean
equalsWithTolerance
(Segment2d other, double tolerance) Returns true if the start and end points of this segment are within tolerance of the start and end points of other in the XY-plane.Returns the end of the segment in the XY-plane.default double
Returns the length of the segment in 2 dimensions.default double
Returns the square of the length of the segment in 2 dimensions.Returns the beginning of the segment in the XY-plane.Returns the point of intersection between this segment and other in the XY-plane.default boolean
intersects
(Segment2d other) Returns true if this segment and other intersect in the XY-plane, otherwise returns false.static Comparator<Segment2d>
Returns a comparator that compares non-null Segments by their length in the XY-plane.sample
(int amount) Samples the given amount of points from the segment.shortestSegmentBetween
(Segment2d segment) Returns the shortest segment from this segment to the given segment in the XY-plane.
-
Method Details
-
create
Creates an new instance.- Parameters:
startPoint
- the start pointendPoint
- the end point- Returns:
- the newly created instance
- Since:
- 9.10.2
-
getStartPoint
Vector2d getStartPoint()Returns the beginning of the segment in the XY-plane.- Returns:
- the beginning of the segment in the XY-plane
- Since:
- 9.10.2
-
getEndPoint
Vector2d getEndPoint()Returns the end of the segment in the XY-plane.- Returns:
- the end of the segment in the XY-plane.
- Since:
- 9.10.2
-
getLengthSquared
default double getLengthSquared()Returns the square of the length of the segment in 2 dimensions.- Returns:
- the square of the length of the segment in 2 dimensions
- Since:
- 9.10.2
-
getLength
default double getLength()Returns the length of the segment in 2 dimensions.- Returns:
- the length of the segment in 2 dimensions
- Since:
- 9.10.2
-
distanceSquared
Returns the square of the minimum distance between this segment and the point in the XY-plane.- Parameters:
point
- the point to which the square of the distance is computed- Returns:
- the square of the minimum distance between this segment and the point in the XY-plane
- Since:
- 9.10.2
-
distance
Returns the minimum distance between this segment and the point in the XY-plane.- Parameters:
point
- the point to which the distance is computed- Returns:
- the minimum distance between this segment and the point in the XY-plane
- Since:
- 9.10.2
-
closestPointTo
Returns the point on this segment that is closest to the given point in the XY-plane. The Z component of the returned vector is set to 0.- Parameters:
point
- the point in the XY-plane for which the closest point on this Segment is computed- Returns:
- the point on this segment that is closest to the given point in the XY-plane
- Since:
- 9.10.2
-
distanceSquared
Returns the square of the minimum distance in the XY-plane between this and the given segment.- Parameters:
other
- the segment to which the square of distance is computed- Returns:
- the square of the minimum distance in the XY-plane between this and the given segment
- Since:
- 9.10.2
-
distance
Returns the minimum distance in the XY-plane between this and the given segment.- Parameters:
other
- the segment to which the distance is computed- Returns:
- the minimum distance in the XY-plane between this and the given segment
- Since:
- 9.10.2
-
intersects
Returns true if this segment and other intersect in the XY-plane, otherwise returns false.- Parameters:
other
- the segment that is checked for intersection- Returns:
- true if this segment and other intersect in the XY-plane, otherwise returns false
- Since:
- 9.10.2
-
intersect
Returns the point of intersection between this segment and other in the XY-plane. If segments do not intersect returns null. Theintersect(Segment2d)
method can be used for checking if segments intersect. The returned vector has its Z component set to 0.- Parameters:
other
- the segment with which the intersection point is computed- Returns:
- an optional that contains the point of intersection between this segment and other in the XY-plane if it exists or an empty optional null if the segments do not intersect
- Since:
- 9.10.2
-
contains
Returns true if the given point lies on this segment in the XY-plane, otherwise returns false.- Parameters:
point
- the point that is checked for being located on this segment- Returns:
- true if the given point lies on this segment in the XY-plane, otherwise returns false
- Since:
- 9.10.2
-
sample
Samples the given amount of points from the segment. The start and end point are not included in the sample. If an amount of zero or less is given, an empty list is returned.- Parameters:
amount
- the amount of samples- Returns:
- the samples as a list from start point towards the end point
-
equalsWithTolerance
Returns true if the start and end points of this segment are within tolerance of the start and end points of other in the XY-plane.- Parameters:
other
- the segment that is checked for equality within tolerancetolerance
- the allowed difference in distance between points- Returns:
- true if the start and end points of this segment are within tolerance of the start and end points of other in the XY-plane
- Since:
- 9.10.2
-
shortestSegmentBetween
Returns the shortest segment from this segment to the given segment in the XY-plane. The returned Segment is not unique if the given Segment instances are parallel. If the segments intersect, then the ends of the returned segment will be equal.- Parameters:
segment
- the target segment for the returned segment- Returns:
- the shortest segment from this segment to the given segment
- Since:
- 9.10.2
-
lengthComparator
Returns a comparator that compares non-null Segments by their length in the XY-plane. The longer segment is considered to be greater in the ordering defined by the comparator returned by this method. This can be used for sorting Segments by length.- Returns:
- comparator that compares segments by length
- Since:
- 9.10.2
-