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
00087
00088
00089
00090
00092
00095
int numCorners() const;
00097
Point<dim> getCorner(
int i) const;
00099
Point<dim> getCenter() const;
00100
00101
00102
00104
Shape& shift(const
Vector<dim>& v);
00106
00109 Shape& moveCornerTo(const
Point<dim>& p,
int corner)
00110 {
return shift(p -
getCorner(corner));}
00112
00115 Shape&
moveCenterTo(
const Point<dim>& p)
00116 {
return shift(p -
getCenter());}
00117
00118
00120
00123 Shape&
rotateCorner(
const RotMatrix<dim>& m,
int corner)
00124 {
return rotatePoint(m,
getCorner(corner));}
00126
00129 Shape&
rotateCenter(
const RotMatrix<dim>& m)
00130 {
return rotatePoint(m,
getCenter());}
00132
00136
Shape& rotatePoint(
const RotMatrix<dim>& m,
const Point<dim>& p);
00137
00138
00139
00141
AxisBox<dim> boundingBox() const;
00143
Ball<dim> boundingSphere() const;
00146
00153
Ball<dim> boundingSphereSloppy() const;
00154
00156
00164 friend
bool Intersect<dim>(
Shape<dim>& s1,
Shape<dim>& s2,
bool proper);
00166
00180 friend
bool Contains<dim>(
Shape<dim>& s1,
Shape<dim>& s2,
bool proper);
00181
00182 private:
00183
bool m_valid;
00184 };
00185
00186
00187
00188 }
00189
00190 #endif