|
Algorithm Development Kit 1.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectalgs.model.twod.TwoDRectangle
public class TwoDRectangle
Represents a rectangular region in the Cartesian plane.
Note that the rectangle could be infinite in none, one, or two of these dimensions by having any of its coordinates set to Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY. A rectangle could be one-dimensional (if either x1==x2 or y1==y2) or zero-dimensional (if both x1==x2 and y1==y2).
RectangularRegion is (slightly) incompatible with IHypercube because rectangles are commonly referred to as (left, bottom, right, top). As you can see, the dimensions are intermixed. IHypercube expects a number of dimensions, and to keep things straight they are reported in order: here this means it would be (left, right) (bottom, top). In order to avoid confusion, we make no attempt to have this class conform to both IRectangle and IHypercube.
Note that for convenience, there is a method in Hypercube that will create a two-dimensional Hypercube counterpart given a RectangularRegion.
IHypercube
Constructor Summary | |
---|---|
TwoDRectangle(double left,
double bottom,
double right,
double top)
Construct a rectangle from the given cartesian coordinates. |
|
TwoDRectangle(IRectangle d)
Copy constructor. |
Method Summary | |
---|---|
boolean |
contains(IRectangle r)
Determines containment of the given rectangle within the closed Rectangular region. |
boolean |
equals(java.lang.Object o)
Extend to cover .equals() to any object that implements IRectangle. |
double |
getBottom()
Return bottom of rectangle. |
double |
getLeft()
Return left of rectangle. |
double |
getRight()
Return right of rectangle. |
double |
getTop()
Return top of rectangle. |
boolean |
intersects(IPoint p)
Determines intersection of the given point within the closed Rectangular region. |
void |
setBottom(double d)
Update bottom of rectangle. |
void |
setLeft(double d)
Update left of rectangle. |
void |
setRight(double d)
Update right of rectangle. |
void |
setTop(double d)
Update top of rectangle. |
java.lang.String |
toString()
Reasonable representation of this rectangular region. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TwoDRectangle(double left, double bottom, double right, double top)
left
- bottom
- right
- top
- public TwoDRectangle(IRectangle d)
Method Detail |
---|
public double getBottom()
getBottom
in interface IRectangle
public double getLeft()
getLeft
in interface IRectangle
public double getRight()
getRight
in interface IRectangle
public double getTop()
getTop
in interface IRectangle
public void setTop(double d)
public void setBottom(double d)
public void setLeft(double d)
public void setRight(double d)
public boolean intersects(IPoint p)
intersects
in interface IRectangle
p
- IPoint to be inspected.public boolean contains(IRectangle r)
Handle -INF and +INF equitably.
contains
in interface IRectangle
r
- Rectangle to be checked for containment within self.public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in interface IRectangle
equals
in class java.lang.Object
Object.equals(Object)
|
Algorithm Development Kit 1.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |