Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkVersor.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkVersor.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-06-14 10:20:48 $
00007   Version:   $Revision: 1.23 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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 
00108   void Set( T x, T y, T z, T w );  
00110 
00111 
00114   Versor();
00115 
00117   Versor(const Self & v);
00118 
00120   const Self& operator=(const Self & v);
00121 
00125   const Self& operator*=(const Self & v);
00126 
00131   const Self& operator/=(const Self & v);
00132 
00133 
00137   ValueType GetTensor(void) const;
00138 
00143   void Normalize(void);
00144 
00147   Self GetConjugate(void) const;
00148 
00152   Self GetReciprocal(void) const;
00153 
00156   Self operator*(const Self &vec) const;
00157 
00159   Self operator/(const Self &vec) const;
00160 
00163   bool operator==(const Self &vec) const;
00164 
00167   bool operator!=(const Self &vec) const;
00168 
00170   ValueType GetScalar( void ) const;
00171 
00173   ValueType GetX( void ) const
00174     { return m_X; }
00175 
00177   ValueType GetY( void ) const
00178     { return m_Y; }
00179 
00181   ValueType GetZ( void ) const
00182     { return m_Z; }
00183 
00185   ValueType GetW( void ) const
00186     { return m_W; }
00187 
00189   ValueType GetAngle( void ) const;
00190 
00193   VectorType GetAxis( void ) const;
00194 
00199   VectorType GetRight( void ) const;
00200 
00204   void Set( const VectorType & axis, ValueType angle );
00205 
00211   void Set( const MatrixType & m );
00212 
00218   void Set( const VectorType & axis );
00219 
00226   void SetRotationAroundX( ValueType angle );
00227 
00234   void SetRotationAroundY( ValueType angle );
00235 
00242   void SetRotationAroundZ( ValueType angle );
00243 
00246   void SetIdentity();
00247 
00249   VectorType Transform( const VectorType & v ) const;
00250 
00252   CovariantVectorType Transform( const CovariantVectorType & v ) const;
00253 
00255   PointType Transform( const PointType & v ) const;
00256 
00258   VnlVectorType Transform( const VnlVectorType & v ) const;
00259 
00261   MatrixType GetMatrix(void) const;
00262 
00264   Self SquareRoot(void) const;
00265 
00269   Self Exponential( ValueType exponent ) const;
00270 
00271 private: 
00273   ValueType  m_X;
00274 
00276   ValueType  m_Y;
00277 
00279   ValueType  m_Z;
00280 
00282   ValueType  m_W;
00283 };
00284 
00285 template< class T>  
00286 ITK_EXPORT std::ostream& operator<<( std::ostream& os, 
00287                                      const Versor<T> & v)
00288 {
00289   os << "[ ";
00290   os << v.GetX() << ", " << v.GetY() << ", ";
00291   os << v.GetZ() << ", " << v.GetW() << " ]";
00292   return os;
00293 }
00294 
00295 template< class T>
00296 ITK_EXPORT std::istream& operator>>(std::istream& is, 
00297                                     Versor<T> & v); 
00298 
00299 
00300 } // end namespace itk
00301   
00302 
00303 // Define instantiation macro for this template.
00304 #define ITK_TEMPLATE_Versor(_, EXPORT, x, y) namespace itk { \
00305   _(1(class EXPORT Versor< ITK_TEMPLATE_1 x >)) \
00306   namespace Templates { typedef Versor< ITK_TEMPLATE_1 x > Versor##y; } \
00307   }
00308 
00309 #if ITK_TEMPLATE_EXPLICIT
00310 # include "Templates/itkVersor+-.h"
00311 #endif
00312 
00313 #if ITK_TEMPLATE_TXX
00314 # include "itkVersor.txx"
00315 #endif
00316 
00317 
00318 #endif 
00319 

Generated at Fri Apr 16 19:58:58 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000