UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
rect.h
Go to the documentation of this file.
1 #ifndef PYRAMIDWORKS_GEOMETRY_RECT_H_
2 #define PYRAMIDWORKS_GEOMETRY_RECT_H_
3 
5 
6 namespace pyramidworks {
7 namespace geometry {
8 
11 class Rect : public GeometricShape {
12  public:
15  Rect(double _width, double _height) : GeometricShape(), half_width_(_width/2), half_height_(_height/2) {}
16 
18 
19  double width() const { return 2*half_width_; }
20 
22 
23  double height() const { return 2*half_height_; }
24 
25  bool Intersects(const ugdk::math::Vector2D& this_pos, const GeometricShape *obj, const ugdk::math::Vector2D& that_pos) const;
26  bool Intersects(const ugdk::math::Vector2D& this_pos, const Rect *obj, const ugdk::math::Vector2D& that_pos) const;
27  bool Intersects(const ugdk::math::Vector2D& this_pos, const Circle *obj, const ugdk::math::Vector2D& that_pos) const;
28  bool Intersects(const ugdk::math::Vector2D& this_pos, const ConvexPolygon *obj, const ugdk::math::Vector2D& that_pos) const;
30 
31  private:
32  double half_width_, half_height_;
33 };
34 
35 } // namespace geometry
36 } // namespace pyramidworks
37 
38 
39 #endif /* PYRAMIDWORKS_GEOMETRY_RECT_H_ */
Definition: vector2D.h:18
double width() const
Returns the rect width.
Definition: rect.h:19
Rect(double _width, double _height)
Definition: rect.h:15
Definition: collisionclass.h:13
ugdk::structure::Box< 2 > GetBoundingBox(const ugdk::math::Vector2D &position) const
Returns a bounding box for this shape.
bool Intersects(const ugdk::math::Vector2D &this_pos, const GeometricShape *obj, const ugdk::math::Vector2D &that_pos) const
Checks if this shape intersects another shape.
Definition: circle.h:11
Definition: geometricshape.h:13
A convex polygon, one type of GeometricShape. This determines a polygon conposed by at least 3 vertic...
Definition: convexpolygon.h:11
double height() const
Returns the rect height.
Definition: rect.h:23
Definition: rect.h:11