Problem 51. Find the two most distant points
Given a collection of points, return the indices of the rows that contain the two points most distant from one another. The input vector p has two columns corresponding to the x and y coordinates of each point. Return ix, the (sorted) pair of indices pointing to the remotest rows. There will always be one unique such pair of points.
So if
p = [0 0] [1 0] [2 2] [0 1]
Then
ix = [1 3]
That is, the two points p(1,:) and p(3,:) are farthest apart.
Solution Stats
Problem Comments
-
7 Comments
refer to
Convex Hull therom and the Graham's Scan method
+1
Nice one!
Solution Comments
Show commentsProblem Recent Solvers2880
Suggested Problems
-
Remove all the words that end with "ain"
2414 Solvers
-
How to find the position of an element in a vector without using the find function
2748 Solvers
-
Back to basics 11 - Max Integer
791 Solvers
-
Are all the three given point in the same line?
584 Solvers
-
917 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!