public class Interval2D extends java.lang.Object
Interval2D
includes methods for checking whether
a two-dimensional interval contains a point and determining whether
two two-dimensional intervals intersect.
For additional documentation, see Section 1.2 of Algorithms, 4th Edition, by Robert Sedgewick and Kevin Wayne.
Constructor and Description |
---|
Interval2D(Interval1D x,
Interval1D y)
Initializes a two-dimensional interval.
|
Modifier and Type | Method and Description |
---|---|
double |
area()
Returns the area of this two-dimensional interval.
|
boolean |
contains(Point2D p)
Does this two-dimensional interval contain the point p?
|
void |
draw()
Draws this two-dimensional interval to standard draw.
|
boolean |
intersects(Interval2D that)
Does this two-dimensional interval intersect that two-dimensional interval?
|
static void |
main(java.lang.String[] args)
Unit tests the Interval2D data type.
|
java.lang.String |
toString()
Returns a string representation of this two-dimensional interval.
|
public Interval2D(Interval1D x, Interval1D y)
x
- the one-dimensional interval of x-coordinatesy
- the one-dimensional interval of y-coordinatespublic boolean intersects(Interval2D that)
that
- the other two-dimensional intervalpublic boolean contains(Point2D p)
p
- the two-dimensional pointpublic double area()
public java.lang.String toString()
toString
in class java.lang.Object
public void draw()
public static void main(java.lang.String[] args)