locked
algorithm to show outermost points in an array of point RRS feed

  • Question

  • I'm looking for an algorithm that when given an array of points will return an array of just the outermost points.  Does anybody have an idea, reference, link, code of how this could be done?

    Sunday, May 25, 2008 9:23 PM

Answers

  • Can you clarify a bit more on what it is you want to do? Do you want to be able to provide an array of random points and then the outer most radial points. If so there is a couple of ways you can do this. One would be to calculate the centerpoint of the array of points. This would be like a center of mass type calculation. Once you do that can calculate the distance and bearing to each point. If the bearing for two or more locations are equal than only keep the point that has the greatest distance from the center point. This, however may return the same array that was entered as it would be hard for two points to have the exact same bearing when javascript uses so many decimal digits. You would probably want to have a buffer of any points within the bearing +/- 1 or 2 degrees.  Note that bearing is the direction in degrees from one point to another. 0 degrees of bearing is North, 90, is East and so on to 360 degrees which is north again.

     

    Sunday, May 25, 2008 11:14 PM
    Moderator