Description
Find the clamped nearest point on a nondegenerate planar segment and its Euclidean distance; finite number arithmetic, not a spatial index.
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.
Find the clamped nearest point on a nondegenerate planar segment and its Euclidean distance; finite number arithmetic, not a spatial index.
When to use this tool
Use this tool to find the clamped nearest point on a nondegenerate planar segment and its Euclidean distance; finite number arithmetic, not a spatial index.
How to use the tool and how it works
- Enter point, start, end using the input definitions below.
- Run the operation. Resolve malformed-input errors before interpreting the result.
- Read result.parameter, result.point, result.distance. Interpret signs, units, ordering and null values using the rules below.
Compute the supporting-line projection parameter, clamp it to [0,1], interpolate the nearest point, and return its Euclidean distance from the supplied point. Reject a zero-length segment.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| point | Planar point [x,y] in the shape’s coordinate units. | Dense list of at most 128 finite numbers, subject to the stated integer/shape rules. |
| 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. |
| Output field | Interpretation |
|---|---|
| result | Object containing the fields below. |
| result.parameter | Nearest-point segment parameter clamped to [0,1]. |
| result.point | Resulting planar [x,y] point in coordinate units. |
| result.distance | Euclidean separation in the supplied coordinate units. |
{
"input": {
"point": [
3,
1
],
"start": [
0,
0
],
"end": [
2,
0
]
},
"output": {
"result": {
"parameter": 1,
"point": [
2,
0
],
"distance": 1.4142135623730951
}
}
} Limitations and assumptions
- Distance uses the planar coordinate units; geographic/geodesic distance and uncertain measurement bounds are outside this model.
- 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
- Point Segment Projection Parameter
Project a point onto the infinite supporting segment line and return the unclamped parameter; a degenerate segment is rejected.
- Rectangle Point Clamp
Clamp a finite planar point to a closed axis-aligned rectangle, allowing degenerate rectangle axes; no polygon or geographic containment.