This Challenge is to determine the minimum distance from a 2-D line segment defined by two points to a point.
The point is (px,py) and the segment is [(vx,vy) to (wx,wy)].
Input are the three defining points and the output is distance.
Input (px py vx vy wx wy): 1 1 0 3 3 0
Output distance: .7071
Point is beyond perpendicular to segment.
Input (px py vx vy wx wy): 4 3 -100 0 0 0
Output distance: 5
Follow Up Challenges:
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers63
Suggested Problems
-
Find the longest sequence of 1's in a binary sequence.
6847 Solvers
-
Given an unsigned integer x, find the largest y by rearranging the bits in x
2070 Solvers
-
Solve the set of simultaneous linear equations
512 Solvers
-
Sum of first n terms of a harmonic progression
521 Solvers
-
Back to basics - mean of corner elements of a matrix
469 Solvers
More from this Author306
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Is a numerical approximation allowed, or should one use the geometric formulas?