Description
Clip one closed planar segment to an inclusive axis-aligned rectangle using parameter bounds; null means no intersection.
Planar geometry operates on two-coordinate Cartesian points and explicit shape boundaries. A closed rectangle includes its edges, while a segment parameter locates a point along a supporting line. Signed cross products, areas and axis gaps preserve orientation or direction information that a magnitude alone would lose.
Clip one closed planar segment to an inclusive axis-aligned rectangle using parameter bounds; null means no intersection.
When to use this tool
Use this tool to clip one closed planar segment to an inclusive axis-aligned rectangle using parameter bounds; null means no intersection.
How to use the tool and how it works
- Enter start, end, rectangle using the input definitions below.
- Run the operation. Resolve malformed-input errors before interpreting the result.
- Read result.segment. Interpret signs, units, ordering and null values using the rules below.
Start with segment parameter bounds [0,1] and tighten them against all four closed rectangle boundaries. Return interpolated endpoints when the final lower bound does not exceed the upper bound; otherwise return null.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| start | Segment start [x,y], corresponding to parameter zero. | Dense list of at most 128 finite numbers, subject to the stated integer/shape rules. |
| end | Segment end [x,y], corresponding to parameter one. | Dense list of at most 128 finite numbers, subject to the stated integer/shape rules. |
| rectangle | Closed rectangle [minX,minY,maxX,maxY]; equal bounds are allowed. | Dense list of at most 128 finite numbers, subject to the stated integer/shape rules. |
| Output field | Interpretation |
|---|---|
| result | Object containing the fields below. |
| result.segment | Two clipped endpoint coordinates, or null when the closed segment misses the rectangle. |
{
"input": {
"start": [
-1,
1
],
"end": [
3,
1
],
"rectangle": [
0,
0,
2,
2
]
},
"output": {
"result": {
"segment": [
[
0,
1
],
[
2,
1
]
]
}
}
} Limitations and assumptions
- Boundary contact and degenerate segments/rectangle axes are retained. Floating comparisons have no robustness tolerance.
- Point components and rectangle bounds are finite within ±1,000,000,000. Rectangles use [minX,minY,maxX,maxY] with ordered inclusive bounds. Floating arithmetic is used without an implicit robustness tolerance.
- Every declared top-level input is required and unknown fields are rejected. Ordinary strings are limited to 8,192 UTF-16 code units and lists to 128 entries, with tighter operation-specific bounds where stated. JSON text has bounded nesting and node counts.
- Numeric outputs must be finite and within the absolute safe-integer magnitude; exact larger integers use decimal text. Source positions are zero-based UTF-16 offsets and span ends are exclusive unless a different convention is explicitly stated.
Alternative or Complementary methods
Choose the boundary and coordinate convention explicitly. Use robust geometric predicates or a topology-aware library when near-coincidence, holes, invalid polygons or geographic coordinates matter.
References
Similar or alternative tools
- Polygon Rectangle Clip
Clip an ordered planar polygon against four rectangle half-planes, preserving algorithm order; floating boundary arithmetic, no polygon topology repair.
- Polyline Rectangle Clip
Clip each polyline segment independently, retaining source-segment indexes and boundary point intersections instead of inventing path continuity.