Commit ed744a09 authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

improvement of localFrame (added some functionalities)

parent 06e4aca5
...@@ -45,7 +45,7 @@ template <typename PFP> ...@@ -45,7 +45,7 @@ template <typename PFP>
class LocalFrame class LocalFrame
{ {
typedef typename PFP::REAL REAL ; typedef typename PFP::REAL REAL ;
typedef typename PFP::VEC2 VEC2 ; typedef typename Geom::Vector<2,REAL> VEC2 ;
typedef typename PFP::VEC3 VEC3 ; typedef typename PFP::VEC3 VEC3 ;
private: // fields private: // fields
...@@ -74,29 +74,51 @@ public: // methods ...@@ -74,29 +74,51 @@ public: // methods
*/ */
VEC3 getCompressed() ; VEC3 getCompressed() ;
/**
* Tests if the frames are identical
* @param lf the frame to compare to the current frame
* @param epsilon the authorized deviation
* @return true if frames are identical (or deviate less than epsilon)
*/
bool equals(const LocalFrame<PFP>& lf, REAL epsilon = 1e-5) const ;
/**
* Equality of frames
* Identical to calling equals with default epsilon
* @return true if frames are identical
*/
bool operator==(const LocalFrame<PFP>& lf) const ;
/**
* Inequality of frames
* Identical to calling !equals with default epsilon
* @return false if frames are identical
*/
bool operator!=(const LocalFrame<PFP>& lf) const ;
/** /**
* Tests if the frame is direct * Tests if the frame is direct
* @return true if the frame is direct * @return true if the frame is direct
*/ */
bool isDirect() ; bool isDirect() const ;
/** /**
* Tests if the frame is orthogonal * Tests if the frame is orthogonal
* @return true if the frame is orthogonal * @return true if the frame is orthogonal
*/ */
bool isOrthogonal() ; bool isOrthogonal() const ;
/** /**
* Tests if the frame is normalized * Tests if the frame is normalized
* @return true if the frame is normalized * @return true if the frame is normalized
*/ */
bool isNormalized() ; bool isNormalized() const ;
/** /**
* Tests if the frame is direct, normalized and orthogonal * Tests if the frame is direct, normalized and orthogonal
* @return true if the frame is direct, normalized and orthogonal * @return true if the frame is direct, normalized and orthogonal
*/ */
bool isOrthoNormalDirect() ; bool isOrthoNormalDirect() const ;
/** /**
* @return current tangent vector * @return current tangent vector
......
...@@ -84,7 +84,29 @@ typename PFP::VEC3 LocalFrame<PFP>::getCompressed() ...@@ -84,7 +84,29 @@ typename PFP::VEC3 LocalFrame<PFP>::getCompressed()
} }
template<typename PFP> template<typename PFP>
bool LocalFrame<PFP>::isDirect() bool LocalFrame<PFP>::equals(const Utils::LocalFrame<PFP>& lf, REAL epsilon) const
{
VEC3 dT = m_T - lf.getT() ;
VEC3 dB = m_B - lf.getB() ;
VEC3 dN = m_N - lf.getN() ;
return dT.norm2() < epsilon && dB.norm2() < epsilon && dN.norm2() < epsilon ;
}
template<typename PFP>
bool LocalFrame<PFP>::operator==(const LocalFrame<PFP>& lf) const
{
return this->equals(lf) ;
}
template<typename PFP>
bool LocalFrame<PFP>::operator!=(const LocalFrame<PFP>& lf) const
{
return !(this->equals(lf)) ;
}
template<typename PFP>
bool LocalFrame<PFP>::isDirect() const
{ {
VEC3 new_B = m_N ^ m_T ; // direct VEC3 new_B = m_N ^ m_T ; // direct
VEC3 diffs = new_B - m_B ; // differences with existing B VEC3 diffs = new_B - m_B ; // differences with existing B
...@@ -94,27 +116,27 @@ bool LocalFrame<PFP>::isDirect() ...@@ -94,27 +116,27 @@ bool LocalFrame<PFP>::isDirect()
} }
template<typename PFP> template<typename PFP>
bool LocalFrame<PFP>::isOrthogonal() bool LocalFrame<PFP>::isOrthogonal() const
{ {
return (abs(m_T * m_B) < 1e-10) && (abs(m_N * m_B) < 1e-10) && (abs(m_T * m_N) < 1e-10) ; return (fabs(m_T * m_B) < 1e-5) && (fabs(m_N * m_B) < 1e-5) && (fabs(m_T * m_N) < 1e-5) ;
} }
template<typename PFP> template<typename PFP>
bool LocalFrame<PFP>::isNormalized() bool LocalFrame<PFP>::isNormalized() const
{ {
return (1-1e-10 < m_N.norm2() && m_N.norm2() < 1+1e-10) return (1-1e-5 < m_N.norm2() && m_N.norm2() < 1+1e-5)
&& (1-1e-10 < m_T.norm2() && m_T.norm2() < 1+1e-10) && (1-1e-5 < m_T.norm2() && m_T.norm2() < 1+1e-5)
&& (1-1e-10 < m_B.norm2() && m_B.norm2() < 1+1e-10) ; && (1-1e-5 < m_B.norm2() && m_B.norm2() < 1+1e-5) ;
} }
template<typename PFP> template<typename PFP>
bool LocalFrame<PFP>::isOrthoNormalDirect() bool LocalFrame<PFP>::isOrthoNormalDirect() const
{ {
return isOrthogonal() && isNormalized() && isDirect() ; return isOrthogonal() && isNormalized() && isDirect() ;
} }
template<typename PFP> template<typename PFP>
typename PFP::VEC2 LocalFrame<PFP>::carthToSpherical (const VEC3& carth) const typename Geom::Vector<2,typename PFP::REAL> LocalFrame<PFP>::carthToSpherical (const VEC3& carth) const
{ {
VEC2 res ; VEC2 res ;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment