package leigh.astro.unit;

/**
 * This class represents a rectangle defined by a pair of {@link SphericalCoordinate}s.
 *
 * @author Alex Leigh
 */
public class Rect {
    private final SphericalCoordinate a;
    private final SphericalCoordinate b;

    public Rect(SphericalCoordinate a, SphericalCoordinate b) {
        this.a = a;
        this.b = b;
    }

    /**
     * Evaluate whether or not the given coordinate is within the coordinates bounded by this object.
     */
    public boolean isWithin(SphericalCoordinate x) {
        return x.getX() >= a.getX() && x.getY() >= a.getY() && x.getX() < b.getX() && x.getY() < b.getY();
    }

    @Override
    public String toString() {
        return "Rect{" +
                "a=" + a +
                ", b=" + b +
                '}';
    }
}
