How to use this tool
- Enter point x, point y, segment start x, segment start y, segment end x, segment end y.
- Select Calculate to view the result.
- Check the method and assumptions below before using the result.
Input reference and sample values
Use the units and choices shown for each field. Sample values are provided for practice, not as recommendations.
| Input | Format and units | Sample |
|---|---|---|
| Point x | Numeric value. | 3 |
| Point y | Numeric value. | 4 |
| Segment start x | Numeric value. | 0 |
| Segment start y | Numeric value. | 0 |
| Segment end x | Numeric value. | 2 |
| Segment end y | Numeric value. | 0 |
Result for these sample inputs
4.12310563 units
- Closest point
- (2, 0)
- Segment parameter
- 1
Select Try the example in the form to load these values and calculate them again. This replaces the current form inputs. Compare the result with the method and worked explanation below.
The method, explained
Project AP onto AB and clamp the parameter t to [0,1]. Distance is from P to A+t(B−A).
Using point x = 3, point y = 4, segment start x = 0, segment start y = 0, segment end x = 2, segment end y = 0, the result is 4.12310563 units. Change these example inputs to match your task; use the method above to check each step.
Understanding your result
Unlike distance to an infinite line, the closest point can be an endpoint. A zero-length segment is treated as a point.
What to keep in mind
Unlike distance to an infinite line, the closest point can be an endpoint. A zero-length segment is treated as a point. Use the indicated units consistently. Ideal shapes are assumed; dimensions must describe the same object. Display rounding does not increase measurement precision.
Methodology maintained by ClarityKit. How these tools are built and checked.