/**
 * The PointUtils class provides utility methods that provide information about
 * Point arrays. All methods are static.
 * 
 * @author Nathan Sprague
 * @version V1.0 8/29/13
 * 
 */
public class PointUtils
{
    /**
     * Return the leftmost point in the array.
     * 
     * @param points
     *            The array of points to search.
     * @return The leftmost point.
     */
    public static Point leftmostPoint(Point[] points)
    {
        Point curLeftmost = points[0];
        for (int i = 1; i < points.length; i++)
        {
            if (points[i].getX() < curLeftmost.getX())
            {
                curLeftmost = points[i];
            }
        }
        return curLeftmost;
    }

    /**
     * Return the top point in the array.
     * 
     * @param points
     *            The array of points to search.
     * @return The top point.
     */
    public static Point topPoint(Point[] points)
    {
        Point curTop = points[1];
        for (int i = 1; i < points.length; i++)
        {
            if (points[i].getY() < curTop.getY())
            {
                curTop = points[i];
            }
        }
        return curTop;
    }
}
