00001
00002
00003 #ifndef _GEOM_HYPERPLANE_HPP_
00004 #define _GEOM_HYPERPLANE_HPP_
00005
00006 #include "geom/Atom.hpp"
00007 #include "geom/Transferrable.hpp"
00008 #include "geom/Angle.hpp"
00009
00010 namespace jafar {
00011 namespace geom {
00012 template<int dimension>
00013 class Point;
00014 template<int dimension>
00015 class Line;
00016 template<int dimension>
00022 class HyperPlane : public Atom<dimension> {
00023 protected:
00024 typedef typename Atom<dimension>::HomogenousVecD HomogenousVecD;
00025 typedef typename Atom<dimension>::HomogenousMatrixD HomogenousMatrixD;
00026 typedef typename Atom<dimension>::HomogenousSymMatrixD HomogenousSymMatrixD;
00027 typedef typename Atom<dimension>::VecD VecD;
00028 typedef Repere<dimension> RepereD;
00029 typedef Point<dimension> PointD;
00030 public:
00034 class Driver : public Atom<dimension>::Driver {
00035 public:
00036 Driver() : Atom<dimension>::Driver()
00037 {}
00038 virtual ~Driver() {}
00042 virtual HomogenousVecD origin() const = 0;
00043 virtual HomogenousSymMatrixD originCov() const = 0;
00047 virtual HomogenousVecD normal() const = 0;
00048 virtual HomogenousSymMatrixD normalCov() const = 0;
00052 virtual HomogenousVecD equation() const = 0;
00056 virtual Driver* clone() const = 0;
00057 };
00058 class EquationDriver : public Driver {
00059 public:
00064 EquationDriver() {};
00065 EquationDriver(const VecD& eqn, double d, const RepereD* reference = RepereD::global());
00066 EquationDriver(const HomogenousVecD& eqn, const RepereD* reference = RepereD::global());
00067 virtual HomogenousVecD origin() const;
00068 virtual HomogenousSymMatrixD originCov() const;
00069 virtual HomogenousVecD normal() const;
00070 virtual HomogenousSymMatrixD normalCov() const;
00071 virtual HomogenousVecD equation() const;
00072 virtual void changeReference( const RepereD* reference );
00073 virtual const RepereD* reference( ) const;
00074 virtual Driver* clone() const;
00075 virtual bool hasCov() const { return false; }
00076 protected:
00077 HomogenousVecD m_eqn;
00078 const RepereD* m_reference;
00079 };
00080 class VectorsDriver : public Driver, public Transferrable<dimension> {
00081 public:
00082 VectorsDriver(const HomogenousVecD& origin, const HomogenousVecD& normal, const RepereD* reference = RepereD::global());
00083 VectorsDriver(const VecD& origin, const VecD& normal, const RepereD* reference = RepereD::global());
00084 void setCov(HomogenousSymMatrixD m_originCov, HomogenousSymMatrixD m_normalCov);
00085 virtual HomogenousVecD origin() const;
00086 virtual HomogenousSymMatrixD originCov() const;
00087 virtual HomogenousVecD normal() const;
00088 virtual HomogenousSymMatrixD normalCov() const;
00089 virtual HomogenousVecD equation() const;
00090 virtual void changeReference( const RepereD* reference );
00091 virtual const RepereD* reference( ) const;
00092 virtual Driver* clone() const;
00093 virtual bool hasCov() const { return m_hasCov; }
00094 private:
00095 HomogenousVecD m_origin, m_normal;
00096 HomogenousSymMatrixD m_originCov, m_normalCov;
00097 const RepereD* m_reference;
00098 bool m_hasCov;
00099 };
00100 public:
00101 HyperPlane(Driver* d);
00102 HyperPlane(const HyperPlane& );
00103 virtual ~HyperPlane();
00104 virtual typename Atom<dimension>::Type type() const { return Atom<dimension>::T_HyperPlane; }
00105 virtual BoundingBox<dimension> boundingBox() const;
00109 inline HomogenousVecD origin() const;
00113 inline HomogenousVecD normal() const;
00114 inline HomogenousSymMatrixD normalCov() const;
00118 inline HomogenousVecD equation() const;
00123 inline HomogenousVecD project(const HomogenousVecD& p) const;
00127 inline HomogenousVecD projectionVector(const HomogenousVecD& p) const;
00132 inline void projectionVectorCov(const HomogenousVecD& p, const HomogenousSymMatrixD& pCov, HomogenousVecD& vec, HomogenousSymMatrixD& cov) const;
00137 inline void projectionVectorCov(const Point<dimension>& p, HomogenousVecD& vec, HomogenousSymMatrixD& cov) const;
00138 public:
00139 GEN_DISTANCE_FUNCTIONS
00140 GEN_ANGLE_FUNCTIONS
00141 GEN_VISITOR_FUNCTIONS
00142 protected:
00143 void setDriver(Driver* driver);
00144 Driver* m_driver;
00145 };
00146 typedef HyperPlane<3> HyperPlane3D;
00147 typedef HyperPlane<2> HyperPlane2D;
00148 }
00149 }
00150
00151 #include "HyperPlaneImpl.hpp"
00152
00153 #endif