|
sdr 0.7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.cscott.sdr.util.Box
public class Box
An orthogonal box, with sides parallel to the x and y axes.
Field Summary | |
---|---|
Point |
ll
|
Point |
ur
|
Constructor Summary | |
---|---|
Box(Point ll,
Point ur)
Basic constructor. |
Method Summary | |
---|---|
Point |
center()
Returns the center of the box. |
boolean |
equals(Object o)
|
int |
hashCode()
|
Fraction |
height()
|
boolean |
includes(Point p)
Returns true iff the given point in inside this box. |
boolean |
overlaps(Box b)
Returns true iff this box overlaps the given one. |
String |
toString()
|
Fraction |
width()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final Point ll
public final Point ur
Constructor Detail |
---|
public Box(Point ll, Point ur)
ll
- Lower-left corner (minimum x, minimum y)ur
- Upper-right corner (maximum x, maximum y)Method Detail |
---|
public Fraction height()
public Fraction width()
public Point center()
js> function f(i) { return Fraction.valueOf(i); }
js> new Box(new Point(f(-1),f(-1)), new Point(f(1),f(1))).center();
0,0
js> new Box(new Point(f(0),f(0)), new Point(f(3),f(4))).center();
1 1/2,2
public boolean overlaps(Box b)
js> function f(i) { return Fraction.valueOf(i); }
js> b1 = new Box(new Point(f(-1),f(-1)), new Point(f(1),f(1)));
(-1,-1;1,1)
js> b2 = new Box(new Point(f(0),f(0)), new Point(f(3),f(3)));
(0,0;3,3)
js> b3 = new Box(new Point(f(-2),f(-2)), new Point(f(0),f(0)));
(-2,-2;0,0)
js> b4 = new Box(new Point(f(1),f(4)), new Point(f(2),f(4)));
(1,4;2,4)
js> b1.overlaps(b2)
true
js> b1.overlaps(b2) == b2.overlaps(b1)
true
js> b1.overlaps(b3)
true
js> b1.overlaps(b3) == b3.overlaps(b1)
true
js> b2.overlaps(b4)
false
js> b2.overlaps(b4) == b4.overlaps(b2)
true
js> b2.overlaps(b3)
false
js> b2.overlaps(b3) == b3.overlaps(b2)
true
js> function f(i) { return Fraction.valueOf(i); }
js> b1 = new Box(new Point(f(-4),f(0)), new Point(f(0),f(2)));
(-4,0;0,2)
js> b2 = new Box(new Point(f(-4),f(-2)), new Point(f(0),f(0)));
(-4,-2;0,0)
js> b1.overlaps(b2)
false
js> b2.overlaps(b1)
false
public boolean includes(Point p)
js> function f(i) { return Fraction.valueOf(i); }
js> b = new Box(new Point(f(-1),f(-1)), new Point(f(1),f(1)));
(-1,-1;1,1)
js> b.includes(new Point(f(0),f(0)))
true
js> b.includes(b.ll)
true
js> b.includes(b.ur)
true
js> b.includes(new Point(f(-1),f(1)))
true
js> b.includes(new Point(f(1),f(-1)))
true
js> b.includes(new Point(f(-2),f(0)))
false
js> b.includes(new Point(f(0),f(2)))
false
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
|
sdr 0.7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |