Go to the documentation of this file.00001
00002
00003
00004 #ifndef ELLIPSE2D_H
00005 #define ELLIPSE2D_H
00006
00007 #include "../BasicDatatypes.hpp"
00008 #include "Point2D.hpp"
00009 #include <iosfwd>
00010 #include <sstream>
00011
00012 namespace datatypes
00013 {
00014
00016
00030 class Ellipse2D : public BasicData
00031 {
00032 public:
00034 typedef Point2D::value_type value_type;
00035 protected:
00036 Point2D m_center;
00037 Point2D m_radius;
00038 value_type m_rotation;
00039 public:
00041 Ellipse2D();
00042
00044
00055 Ellipse2D(const Point2D& center, const Point2D& radius, value_type rotation = 0.0);
00056
00058
00078 Ellipse2D(value_type x_center, value_type y_center, value_type x_radius, value_type y_radius, value_type rotation = 0.0);
00079
00080
00081
00082 virtual const UINT32 getUsedMemory() const { return sizeof(*this); };
00083
00085
00086
00088 const Point2D& getCenter() const { return m_center; }
00089
00091
00097 const Point2D& getRadius() const { return m_radius; }
00098
00104 value_type getRotation() const { return m_rotation; }
00105
00106
00107
00108
00110
00111
00113 void setCenter(const Point2D& p) { m_center = p; }
00114
00116 void setCenter(value_type x, value_type y) { m_center.setXY(x, y); }
00117
00119 void setRadius(const Point2D& p);
00120
00122 void setRadius(value_type x_length, value_type y_width);
00123
00131 void setRotation(value_type r);
00132
00133
00134
00135
00137
00138
00140
00145 bool containsPoint(const Point2D& point) const;
00146
00147
00148
00149 std::string toString() const;
00150
00151
00152 friend inline bool operator==(const Ellipse2D &, const Ellipse2D &);
00153 friend inline bool operator!=(const Ellipse2D &, const Ellipse2D &);
00154
00155 private:
00156 void verifyNumericRanges();
00157
00158 };
00159
00160
00161 inline bool operator==(const Ellipse2D &b1, const Ellipse2D &b2)
00162 {
00163 return (b1.m_center == b2.m_center)
00164 && (b1.m_radius == b2.m_radius)
00165 && (fuzzyCompare(b1.m_rotation,
00166 b2.m_rotation)
00167 || (isNaN(b1.m_rotation) && isNaN(b2.m_rotation)));
00168 }
00169
00170 inline bool operator!=(const Ellipse2D &b1, const Ellipse2D &b2)
00171 {
00172 return ! operator==(b1, b2);
00173 }
00174
00175 }
00176
00177 #endif // ELLIPSE2D_H