Class FarthestPointPair

java.lang.Object
micycle.pgs.commons.FarthestPointPair

public class FarthestPointPair extends Object
The FarthestPair data type computes the farthest pair of points in a set of n points in the plane and provides accessor methods for getting the farthest pair of points and the distance between them. The distance between two points is their Euclidean distance.

This implementation computes the convex hull of the set of points and uses the rotating calipers method to find all antipodal point pairs and the farthest pair. It runs in O(n log n) time in the worst case and uses O(N) extra space.

Author:
Robert Sedgewick, Kevin Wayne, Adapted by Michael Carleton
  • Constructor Summary

    Constructors
    Constructor
    Description
    FarthestPointPair(Collection<processing.core.PVector> points)
    Computes the farthest pair of points in the specified array of points.
  • Method Summary

    Modifier and Type
    Method
    Description
    processing.core.PVector
    Returns one of the points in the farthest pair of points.
    processing.core.PVector
    Returns the other point in the farthest pair of points.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FarthestPointPair

      public FarthestPointPair(Collection<processing.core.PVector> points)
      Computes the farthest pair of points in the specified array of points.
      Parameters:
      points - an array of points
  • Method Details

    • either

      public processing.core.PVector either()
      Returns one of the points in the farthest pair of points.
      Returns:
      one of the two points in the farthest pair of points; null if no such point (because there are fewer than 2 points)
    • other

      public processing.core.PVector other()
      Returns the other point in the farthest pair of points.
      Returns:
      the other point in the farthest pair of points null if no such point (because there are fewer than 2 points)