4 * Created on: Apr 19, 2012
8 #ifndef GEOMETRY_CIRCLE_H_
9 #define GEOMETRY_CIRCLE_H_
24 Circle(void) : position(), radius() { };
25 explicit Circle(Scalar radius) : position(), radius(radius) { };
26 explicit Circle(const Vector &position, Scalar radius = Scalar()) : position(position), radius(radius) { };
27 virtual ~Circle(void) { };
30 Scalar X(void) const { return position.X(); };
31 Scalar Y(void) const { return position.Y(); };
32 Scalar Radius(void) const { return radius; };
33 Scalar Diameter(void) const { return 2 * Radius(); };
35 Scalar Width(void) const { return Diameter(); };
36 Scalar Height(void) const { return Diameter(); };
38 Scalar Left(void) const { return X() - Radius(); };
39 Scalar Top(void) const { return Y() - Radius(); };
40 Scalar Right(void) const { return X() + Radius(); };
41 Scalar Bottom(void) const { return Y() + Radius(); };
44 virtual bool Overlaps(const Shape &other, Vector &normal) const;
45 virtual bool Overlaps(const AABB &other, Vector &normal) const;
46 virtual bool Overlaps(const Circle &other, Vector &normal) const;
47 virtual bool Overlaps(const FakeLens &, Vector &normal) const;
49 bool VerticalOverlap(const AABB &other) const {
50 if (Bottom() < other.Top()) return false;
51 if (other.Bottom() < Top()) return false;
54 bool HorizontalOverlap(const AABB &other) const {
55 if (Right() < other.Left()) return false;
56 if (other.Right() < Left()) return false;
61 void Move(const Vector &delta) {
65 void SetPosition(const Vector &pos) {
68 void SetRadius(Scalar r) {
72 virtual Vector Center(void) const {
76 virtual std::ostream &Write(std::ostream &out) const;
86 #endif /* GEOMETRY_CIRCLE_H_ */