4 * Created on: Apr 30, 2012
15 /// An axes aligned bounding box.
16 /// This shape cannot be rotated.
22 AABB(Scalar width, Scalar height) : leftTop(-width/2, -height/2), rightBottom(width/2, height/2) { };
23 virtual ~AABB(void) { };
26 Scalar Left(void) const { return leftTop.X(); };
27 Scalar Top(void) const { return leftTop.Y(); };
28 Scalar Right(void) const { return rightBottom.X(); };
29 Scalar Bottom(void) const { return rightBottom.Y(); };
31 Vector Center(void) const { return leftTop + (rightBottom - leftTop) / 2; };
32 Scalar Width(void) const { return Right() - Left(); };
33 Scalar Height(void) const { return Bottom() - Top(); };
36 virtual void Translate(const Vector &delta);
37 virtual void Rotate(Scalar delta);
40 virtual bool CheckCollision(const Shape &, Ray &) const;
41 virtual bool CheckCollision(const AABB &, Ray &) const;
42 virtual bool CheckCollision(const Circle &, Ray &) const;
45 virtual std::ostream &Write(std::ostream &) const;
48 Vector leftTop, rightBottom;
54 #endif /* SHAPE_AABB_H_ */