00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkVersor_h
00018 #define __itkVersor_h
00019
00020 #include "itkVector.h"
00021 #include "itkPoint.h"
00022 #include "itkMatrix.h"
00023 #include "itkCovariantVector.h"
00024 #include "vnl/vnl_quaternion.h"
00025 #include "vnl/vnl_vector_fixed.h"
00026
00027 namespace itk
00028 {
00029
00051 template<class T>
00052 class Versor
00053 {
00054 public:
00056 typedef Versor Self;
00057
00060 typedef T ValueType;
00061
00063 typedef typename NumericTraits<ValueType>::RealType RealType;
00064
00066 typedef Vector<T,3> VectorType;
00067
00069 typedef Point<T,3> PointType;
00070
00072 typedef CovariantVector<T,3> CovariantVectorType;
00073
00075 typedef vnl_vector_fixed<T,3> VnlVectorType;
00076
00078 typedef vnl_quaternion<T> VnlQuaternionType;
00079
00081 typedef Matrix<T,3,3> MatrixType;
00082
00084 vnl_quaternion<T> GetVnlQuaternion( void ) const;
00085
00089 void Set( const VnlQuaternionType & );
00090
00094 void Set( T x, T y, T z, T w );
00095
00096
00099 Versor();
00100
00102 Versor(const Self & v);
00103
00105 const Self& operator=(const Self & v);
00106
00110 const Self& operator*=(const Self & v);
00111
00116 const Self& operator/=(const Self & v);
00117
00118
00122 ValueType GetTensor(void) const;
00123
00128 void Normalize(void);
00129
00132 Self GetConjugate(void) const;
00133
00137 Self GetReciprocal(void) const;
00138
00141 Self operator*(const Self &vec) const;
00142
00144 Self operator/(const Self &vec) const;
00145
00148 bool operator==(const Self &vec) const;
00149
00152 bool operator!=(const Self &vec) const;
00153
00155 ValueType GetScalar( void ) const;
00156
00158 ValueType GetX( void ) const
00159 { return m_X; }
00160
00162 ValueType GetY( void ) const
00163 { return m_Y; }
00164
00166 ValueType GetZ( void ) const
00167 { return m_Z; }
00168
00170 ValueType GetW( void ) const
00171 { return m_W; }
00172
00174 ValueType GetAngle( void ) const;
00175
00178 VectorType GetAxis( void ) const;
00179
00184 VectorType GetRight( void ) const;
00185
00189 void Set( const VectorType & axis, ValueType angle );
00190
00196 void Set( const MatrixType & m );
00197
00203 void Set( const VectorType & axis );
00204
00211 void SetRotationAroundX( ValueType angle );
00212
00219 void SetRotationAroundY( ValueType angle );
00220
00227 void SetRotationAroundZ( ValueType angle );
00228
00231 void SetIdentity();
00232
00234 VectorType Transform( const VectorType & v ) const;
00235
00237 CovariantVectorType Transform( const CovariantVectorType & v ) const;
00238
00240 PointType Transform( const PointType & v ) const;
00241
00243 VnlVectorType Transform( const VnlVectorType & v ) const;
00244
00246 MatrixType GetMatrix(void) const;
00247
00249 Self SquareRoot(void) const;
00250
00254 Self Exponential( ValueType exponent ) const;
00255
00256 private:
00258 ValueType m_X;
00259
00261 ValueType m_Y;
00262
00264 ValueType m_Z;
00265
00267 ValueType m_W;
00268 };
00269
00270 template< class T>
00271 ITK_EXPORT std::ostream& operator<<( std::ostream& os,
00272 const Versor<T> & v)
00273 {
00274 os << "[ ";
00275 os << v.GetX() << ", " << v.GetY() << ", ";
00276 os << v.GetZ() << ", " << v.GetW() << " ]";
00277 return os;
00278 }
00279
00280 template< class T>
00281 ITK_EXPORT std::istream& operator>>(std::istream& is,
00282 Versor<T> & v);
00283
00284
00285 }
00286
00287
00288
00289 #define ITK_TEMPLATE_Versor(_, EXPORT, x, y) namespace itk { \
00290 _(1(class EXPORT Versor< ITK_TEMPLATE_1 x >)) \
00291 namespace Templates { typedef Versor< ITK_TEMPLATE_1 x > Versor##y; } \
00292 }
00293
00294 #if ITK_TEMPLATE_EXPLICIT
00295 # include "Templates/itkVersor+-.h"
00296 #endif
00297
00298 #if ITK_TEMPLATE_TXX
00299 # include "itkVersor.txx"
00300 #endif
00301
00302
00303 #endif
00304