00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef WFMATH_SHAPE_H
00031 #define WFMATH_SHAPE_H
00032
00033 #include <wfmath/vector.h>
00034 #include <wfmath/point.h>
00035 #include <wfmath/const.h>
00036 #include <wfmath/rotmatrix.h>
00037 #include <wfmath/axisbox.h>
00038 #include <wfmath/ball.h>
00039 #include <wfmath/intersect_decls.h>
00040
00041 namespace WFMath {
00042
00044
00055 template<const int dim>
00056 class Shape
00057 {
00058 public:
00059
00060
00061
00063 Shape() {}
00065 Shape(const Shape<dim>& s) {}
00067 ~Shape() {}
00068
00070 friend std::ostream& operator<< <dim>(std::ostream& os, const Shape& s);
00072 friend std::istream& operator>> <dim>(std::istream& is, Shape& s);
00073
00075 Shape& operator=(const Shape& a);
00076
00078 bool isEqualTo(const Shape& s, double tolerance = WFMATH_EPSILON) const;
00080 bool operator==(const Shape& s) const {return isEqualTo(s);}
00082 bool operator!=(const Shape& s) const {return !isEqualTo(s);}
00083
00085 bool isValid() const {return m_valid;}
00086
00088
00092 bool operator< (const Shape& a) const;
00093
00094
00095
00096
00097
00099
00102 int numCorners() const;
00104
00106
00107
00108
00109
00111 Shape& shift(const Vector<dim>& v);
00113
00116 Shape& moveCornerTo(const Point<dim>& p, int corner)
00117 {return shift(p - getCorner(corner));}
00119
00122 Shape& moveCenterTo(const Point<dim>& p)
00123 {return shift(p - getCenter());}
00124
00125
00127
00130 Shape& rotateCorner(const RotMatrix<dim>& m, int corner)
00131 {return rotatePoint(m, getCorner(corner));}
00133
00136 Shape& rotateCenter(const RotMatrix<dim>& m)
00137 {return rotatePoint(m, getCenter());}
00139
00143 Shape& rotatePoint(const RotMatrix<dim>& m, const Point<dim>& p);
00144
00145
00146
00148 AxisBox<dim> boundingBox() const;
00150 Ball<dim> boundingSphere() const;
00153
00160 Ball<dim> boundingSphereSloppy() const;
00161
00163
00171 friend bool Intersect<dim>(Shape<dim>& s1, Shape<dim>& s2, bool proper);
00173
00187 friend bool Contains<dim>(Shape<dim>& s1, Shape<dim>& s2, bool proper);
00188
00189 private:
00190 bool m_valid;
00191 };
00192
00193
00194
00195 }
00196
00197 #endif // WFMATH_SHAPE_H