Solved

Points form a line. How can I find the most distant points?

Posted on 2011-02-22
5
344 Views
Last Modified: 2012-05-11
Hello experts!

I have set of points.
I know that they form a line.

I need to find two most distant points (start and end of line).

How can I do it?

Thank you

panJames
0
Comment
Question by:panJames
  • 2
  • 2
5 Comments
 
LVL 32

Expert Comment

by:phoffric
ID: 34952669
How about sorting the set of points, { (xi, yi) } by the key x.
The first point (x_min, y1) and the last point (x_max, y2) should be the two most distant points.

If the slope of the line is positive, then y1 should be y_min; otherwise y1 should be y_max.
0
 
LVL 32

Accepted Solution

by:
phoffric earned 500 total points
ID: 34952683
If the line is vertical, the all x's are the same. So, if x_min = x_max, then start over and sort all the points by the key y.
0
 
LVL 12

Expert Comment

by:Amick
ID: 34952686
What do you know about the points?  Do you have their coordinates?  
0
 
LVL 27

Expert Comment

by:d-glitch
ID: 34952851
The ends of the line segment must include the maximum and minimum values of
x and y.

If the line is vertical, the max and min values of x will be the same.

If the line is horizontal, the max and min values of y will be the same.

If the slope of the line is positive, the max and min values of x will be paired
with the max and min values of y respectively.

If the slope is negative, the max and min values of x will be paired
with the min and max values of y respectively.
0
 
LVL 27

Expert Comment

by:d-glitch
ID: 34952865
You don't have to sort, all you have to do is find the max and min.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Complex Numbers are funny things.  Many people have a basic understanding of them, some a more advanced.  The confusion usually arises when that pesky i (or j for Electrical Engineers) appears and understanding the meaning of a square root of a nega…
Lithium-ion batteries area cornerstone of today's portable electronic devices, and even though they are relied upon heavily, their chemistry and origin are not of common knowledge. This article is about a device on which every smartphone, laptop, an…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now