Overview
Point-to-segment distance projects the point onto the segment's supporting line, clamps the projection parameter to the segment endpoints, and measures the resulting Euclidean distance.
Computes the shortest distance from a point to a finite line segment.
Compact metadata for implementation and discovery.
Point-to-segment distance projects the point onto the segment's supporting line, clamps the projection parameter to the segment endpoints, and measures the resulting Euclidean distance.
Quick facts
Runtime and memory behavior at a glance.
Best
O(1)
Average
O(1)
Worst
O(1)
Space
O(1)
t = clamp(dot(p-a, b-a) / dot(b-a, b-a), 0, 1)Finds the closest point on a segment to the query point.
Show projecting a point onto a segment and clamping the parameter on a small point distance query example.
The clamping step is the difference between point-to-line and point-to-segment distance.
What each reference supports for this entry.
Computational geometry textbook support for Point-to-Segment Distance's geometric model, data structures, and robustness concerns.
Open sourceAlgorithm catalog support for Point-to-Segment Distance's problem context, known alternatives, and practical selection tradeoffs.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Geometry · Foundation
Both use distance queries ideas for related point distance query problems.
Compare with thisGeometry · Core
Both use distance queries ideas for related point distance query problems.
Compare with thisBoth use distance queries ideas for related point distance query problems.
Both use distance queries ideas for related point distance query problems.
Both use distance queries ideas for related point distance query problems.