Method ClipTo
- Namespace
- GeometryHelper.Geometry
- Assembly
- GeometryHelper.dll
ClipTo(GeoRectangle2)
Gets the part of this line inside a rectangle, using the default tolerance.
public GeoLine2? ClipTo(GeoRectangle2 rect)
Parameters
rectGeoRectangle2
Returns
- GeoLine2?
The segment where the line is inside the rectangle, running along the direction of the line; null when it misses.
Exceptions
- ArgumentException
Thrown when the rectangle has a coordinate or a size that is not a finite number.
- InvalidOperationException
Thrown when this line has a coordinate that is not a finite number.
ClipTo(GeoRectangle2, Tolerance)
Gets the part of this line inside a rectangle, within a tolerance.
public GeoLine2? ClipTo(GeoRectangle2 rect, Tolerance tolerance)
Parameters
rectGeoRectangle2The rectangle.
toleranceToleranceThe tolerance: a line that misses the rectangle by no more than the point tolerance is clipped to the rectangle grown by it.
Returns
- GeoLine2?
The segment where the line is inside the rectangle, running along the direction of the line; null when it misses.
Remarks
Meant for drawing: the line through (-50, 50) along X, clipped to the square 100 by 100 with a corner at the origin, is the segment from (0, 50) to (100, 50); the line along Y through (150, 0) misses it and gives null.
A line that crosses the rectangle is clipped to it exactly. One that misses it by no more than the point tolerance, the line along X through (0, 100.0005) over that square, touches it as CollidesWith(GeoRectangle2) says, and is clipped to the rectangle grown by the tolerance: from (-0.001, 100.0005) to (100.001, 100.0005), its ends no more than the tolerance outside the rectangle on either axis. One that misses it by more gives null.
Exceptions
- ArgumentException
Thrown when the rectangle has a coordinate or a size that is not a finite number.
- InvalidOperationException
Thrown when this line has a coordinate that is not a finite number.