FarthestPair Class |
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. See also and .
Namespace: Algs4Net
public class FarthestPair
The FarthestPair type exposes the following members.
Name | Description | |
---|---|---|
![]() | FarthestPair |
Computes the farthest pair of points in the specified array of points. |
Name | Description | |
---|---|---|
![]() | Either |
Returns one of the points in the closest pair of points. |
![]() | Other |
Returns the other point in the closest pair of points. |
Name | Description | |
---|---|---|
![]() | Distance |
Returns the Eucliden distance between the closest pair of points.
This quantity is also known as the Diameter of the set of points. |
![]() ![]() | MainTest |
Demo test the FarthestPair data type.
Reads in an integer N and N points (specified by
their X- and Y-coordinates) from standard input;
computes a farthest pair of points; and prints the pair to standard
output. |
For additional documentation, see Section 9.9 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
This class is a C# port from the original Java class FarthestPair implementation by the respective authors.