@Test public void testIntersects() { Box2D box0=new Box2D(new Vector2(0,0), new Vector2(1,1)); Box2D box1=new Box2D(new Vector2(0.25,0.25), new Vector2(0.5,0.5)); Box2D box2=new Box2D(new Vector2(1.25,1.25), new Vector2(1.5,1.5)); assertTrue(box0.intersects(box1)); assertFalse(box0.intersects(box2)); }
public boolean intersects(Box2D bb) { return Math.max(min.getX(), bb.getMin().getX()) <= Math.min(max.getX(), bb.getMax().getX()) && Math.max(min.getY(), bb.getMin().getY()) <= Math.min(max.getY(), bb.getMax().getY()); }
Box2D implements IsSerializable { public boolean intersects(Box2D bb) { return Math.max(min.getX(), bb.getMin().getX()) <= Math.min(max.getX(), bb.getMax().getX()) && Math.max(min.getY(), bb.getMin().getY()) <= Math.min(max.getY(), bb.getMax().getY()); } }
Box2D implements IsSerializable { public boolean intersects(Box2D bb) { return Math.max(min.getX(), bb.getMin().getX()) <= Math.min(max.getX(), bb.getMax().getX()) && Math.max(min.getY(), bb.getMin().getY()) <= Math.min(max.getY(), bb.getMax().getY()); } Box2D();  Box2D(Vector2 min, Vector2 max); }
Box2D implements IsSerializable { public boolean intersects(Box2D bb) { return Math.max(min.getX(), bb.getMin().getX()) <= Math.min(max.getX(), bb.getMax().getX()) && Math.max(min.getY(), bb.getMin().getY()) <= Math.min(max.getY(), bb.getMax().getY()); } Box2D();  Box2D(Vector2 min, Vector2 max); Box2D clone(); Boolean valid(); Vector2 getMin(); void setMin(Vector2 min); Vector2 getMax(); void setMax(Vector2 max); void expandBy(Vector2 v); void expandBy(Box2D bb); void expandBy(double d); boolean intersects(Box2D bb); boolean contains(Vector2 position); Vector2 getCenter(); double getWidth(); double getHeight(); String toString(); static Box2D createBox(Vector2 v0, Vector2 v1); String toJSON(); }
Box2D implements IsSerializable { public boolean intersects(Box2D bb) { return Math.max(min.getX(), bb.getMin().getX()) <= Math.min(max.getX(), bb.getMax().getX()) && Math.max(min.getY(), bb.getMin().getY()) <= Math.min(max.getY(), bb.getMax().getY()); } Box2D();  Box2D(Vector2 min, Vector2 max); Box2D clone(); Boolean valid(); Vector2 getMin(); void setMin(Vector2 min); Vector2 getMax(); void setMax(Vector2 max); void expandBy(Vector2 v); void expandBy(Box2D bb); void expandBy(double d); boolean intersects(Box2D bb); boolean contains(Vector2 position); Vector2 getCenter(); double getWidth(); double getHeight(); String toString(); static Box2D createBox(Vector2 v0, Vector2 v1); String toJSON();  }