Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
repere.hpp
00001 #ifndef _REPERE_H_
00002 #define _REPERE_H_
00003 
00004 #include <kernel/jafarMacro.hpp>
00005 #include <geom/t3dEuler.hpp>
00006 #include <jmath/jblas.hpp>
00007 
00008 #include "facetsmap/functions.hpp"
00009 
00010 namespace jafar {
00011 namespace facetsmap {
00012   class Repere {
00013     private:
00017       inline Repere() : m_ref(0) , m_t3d_uptodate(false) {
00018         JFR_DEBUG("Construct the global reference");
00019         initIdentityRepere();
00020       };
00021       void initIdentityRepere();
00022     public:
00026       inline Repere(const Repere* ref, jblas::vec3 origin,jblas::vec3 i, jblas::vec3 j, jblas::vec3 k) :
00027         m_ref(ref), m_i(i), m_j(j), m_k(k), m_origin(origin), m_t3d_uptodate(false)
00028       {
00029         if(m_ref==0) m_ref = global();
00030       };
00035       inline Repere(const Repere* ref) : m_ref(ref), m_t3d_uptodate(false)
00036       {
00037         if(m_ref==0) m_ref = global();
00038         initIdentityRepere();
00039       };
00040     public:
00041       static inline Repere* copyRepere(Repere* r)
00042       {
00043         return new Repere(r->ref(), r->origin(), r->i(),r->j(),r->k());
00044       }
00045       static inline const Repere* global()
00046       { return (s_globalRef == 0) ? (s_globalRef = new Repere()) : s_globalRef ; }
00051       inline const Repere* ref() const { return m_ref; }
00055       void changeRef(const Repere*);
00059       inline void setRef(const Repere* ref) { m_ref = ref; }
00063       inline bool isGlobal() const { return (m_ref == 0); }
00067       inline jblas::vec3 i() const { return m_i; };
00071       inline jblas::vec3 j() const { return m_j; };
00075       inline jblas::vec3 k() const { return m_k; };
00079       inline jblas::vec3 origin() const { return m_origin; };
00080       
00081       inline jblas::vec3 globalOrigin() const { if(isGlobal()) return origin(); else return ref()->localToGlobal(origin(),1); }
00082       
00086       jblas::vec toEuler() const;
00087       void fromEuler(const jblas::vec&);
00088     public: // Formula to change the repere
00089 /*      jblas::vec3 absoluteLocalToParent(jblas::vec3 ) const;
00090       jblas::vec3 absoluteParentToLocal(jblas::vec3 ) const;
00091       jblas::vec3 absoluteLocalToGlobal(jblas::vec3 ) const;
00092       jblas::vec3 absoluteGlobalToLocal(jblas::vec3 ) const;
00093       jblas::vec3 relativeLocalToParent(jblas::vec3 ) const;
00094       jblas::vec3 relativeParentToLocal(jblas::vec3 ) const;
00095       jblas::vec3 relativeLocalToGlobal(jblas::vec3 ) const;
00096       jblas::vec3 relativeGlobalToLocal(jblas::vec3 ) const;
00097       jblas::vec3 absoluteTransformTo(jblas::vec3, const Repere*) const;
00098       jblas::vec3 relativeTransformTo(jblas::vec3, const Repere*) const;*/
00099       inline jblas::vec3 localToGlobal(jblas::vec3 v, double l) const {
00100         if(isGlobal()) return v;
00101         jblas::mat44 localToGlobalMat = localToGlobal().getM();
00102         return prodMat44byVec3(localToGlobalMat, v, l);
00103       }
00104       geom::T3DEuler localToParent() const;
00105       void localToParent(geom::T3DEuler&) const;
00106       geom::T3DEuler parentToLocal() const;
00107       void parentToLocal(geom::T3DEuler&) const;
00108       geom::T3DEuler localToGlobal() const;
00109       void localToGlobal(geom::T3DEuler&) const;
00110       geom::T3DEuler globalToLocal() const;
00111       void globalToLocal(geom::T3DEuler&) const;
00112     protected:
00116       inline void setI(jblas::vec3 ni) { m_t3d_uptodate = false; m_i = ni; };
00120       inline void setJ(jblas::vec3 nj) { m_t3d_uptodate = false; m_j = nj; };
00124       inline void setK(jblas::vec3 nk) { m_t3d_uptodate = false; m_k = nk; };
00128       inline void setOrigin(jblas::vec3 no) { m_t3d_uptodate = false; m_origin = no; };
00129     private:
00130       static Repere* s_globalRef;
00131       const Repere* m_ref;
00132       jblas::vec3 m_i,m_j,m_k, m_origin;
00133       mutable bool m_t3d_uptodate;
00134       mutable geom::T3DEuler m_thisToRef;
00135   };
00136 
00137 };
00138 };
00139 
00140 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:18 for Jafar by doxygen 1.7.6.1
LAAS-CNRS