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

itkAffineTransform.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkAffineTransform.h,v $
00005   Language:  C++
00006   Date:      $Date: 2002/10/11 20:56:04 $
00007   Version:   $Revision: 1.45 $
00008 
00009   Copyright (c) 2002 Insight 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 
00018 #ifndef __itkAffineTransform_h
00019 #define __itkAffineTransform_h
00020 
00021 #include <iostream>
00022 
00023 #include "itkMatrix.h"
00024 #include "itkTransform.h"
00025 #include "itkExceptionObject.h"
00026 #include "itkMacro.h"
00027 
00028 namespace itk
00029 {
00030 
00031 
00099 template <
00100  class TScalarType=double,         // Data type for scalars (e.g. float or double)
00101  unsigned int NDimensions=3>       // Number of dimensions in the input space
00102 class AffineTransform : public Transform< TScalarType,
00103                                           NDimensions, 
00104                                           NDimensions >
00105 {
00106 public:
00108   typedef AffineTransform  Self;
00109   typedef Transform< TScalarType, NDimensions, NDimensions >  Superclass;
00110   typedef SmartPointer<Self>        Pointer;
00111   typedef SmartPointer<const Self>  ConstPointer;
00112   
00114   itkTypeMacro( AffineTransform, Transform );
00115 
00117   itkNewMacro( Self );
00118 
00120   itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
00121   itkStaticConstMacro(ParametersDimension, unsigned int,
00122                       NDimensions*(NDimensions+1));
00123 
00124   
00126   typedef typename Superclass::ParametersType  ParametersType;
00127 
00129   typedef typename Superclass::JacobianType  JacobianType;
00130 
00132   typedef typename Superclass::ScalarType ScalarType;
00133 
00135   typedef Vector<TScalarType,
00136                  itkGetStaticConstMacro(SpaceDimension)>  InputVectorType;
00137   typedef Vector<TScalarType,
00138                  itkGetStaticConstMacro(SpaceDimension)>  OutputVectorType;
00139   
00141   typedef CovariantVector<TScalarType,
00142                           itkGetStaticConstMacro(SpaceDimension)>  InputCovariantVectorType;
00143   typedef CovariantVector<TScalarType,
00144                           itkGetStaticConstMacro(SpaceDimension)>  OutputCovariantVectorType;
00145   
00147   typedef vnl_vector_fixed<TScalarType,
00148                            itkGetStaticConstMacro(SpaceDimension)> InputVnlVectorType;
00149   typedef vnl_vector_fixed<TScalarType,
00150                            itkGetStaticConstMacro(SpaceDimension)> OutputVnlVectorType;
00151   
00153   typedef Point<TScalarType,
00154                 itkGetStaticConstMacro(SpaceDimension)> InputPointType;
00155   typedef Point<TScalarType,
00156                 itkGetStaticConstMacro(SpaceDimension)> OutputPointType;
00157   
00159   typedef Matrix<TScalarType, itkGetStaticConstMacro(SpaceDimension),
00160                  itkGetStaticConstMacro(SpaceDimension)> MatrixType;
00161 
00163   typedef     OutputVectorType    OffsetType;
00164 
00168   const OffsetType & GetOffset(void) const
00169       { return m_Offset; }
00170 
00175   const MatrixType & GetMatrix() const
00176       { return m_Matrix; }
00177 
00181   void SetIdentity( void )
00182     { m_Matrix.SetIdentity();
00183     m_Offset.Fill( 0.0 ); }
00184 
00192   const MatrixType & GetInverse() const
00193     { if( m_Singular ) { throw ExceptionObject(__FILE__, __LINE__); }
00194     return m_Inverse; 
00195     }
00196 
00202   void SetOffset(const OffsetType &offset)
00203       { m_Offset = offset; return; }
00204 
00209   void SetMatrix(const MatrixType &matrix)
00210       { m_Matrix = matrix; RecomputeInverse(); return; }
00211 
00215   void SetParameters( const ParametersType & parameters );
00216 
00218   const ParametersType& GetParameters(void) const;
00219 
00230   void Compose(const Self * other, bool pre=0);
00231 
00237   void Translate(const OutputVectorType &offset, bool pre=0);
00238 
00249   void Scale(const OutputVectorType &factor, bool pre=0);
00250   void Scale(const TScalarType &factor, bool pre=0);
00251 
00266   void Rotate(int axis1, int axis2, TScalarType angle, bool pre=0);
00267 
00280   void Rotate2D(TScalarType angle, bool pre=0);
00281 
00294   void Rotate3D(const OutputVectorType &axis, TScalarType angle, bool pre=0);
00295 
00305   void Shear(int axis1, int axis2, TScalarType coef, bool pre=0);
00306 
00314   OutputPointType     TransformPoint (const InputPointType  &point ) const;
00315   OutputVectorType    TransformVector(const InputVectorType &vector) const;
00316   OutputVnlVectorType TransformVector(const InputVnlVectorType &vector) const;
00317   OutputCovariantVectorType TransformCovariantVector(
00318                              const InputCovariantVectorType &vector) const;
00319   
00325   inline InputPointType   BackTransform(const OutputPointType  &point ) const;
00326   inline InputVectorType  BackTransform(const OutputVectorType &vector) const;
00327   inline InputVnlVectorType BackTransform(const OutputVnlVectorType &vector) const;
00328 
00329   inline InputCovariantVectorType BackTransform(
00330                               const OutputCovariantVectorType &vector) const;
00331 
00338   InputPointType  BackTransformPoint(const OutputPointType  &point) const;
00339 
00345   AffineTransform::Pointer Inverse(void) const;
00346 
00358   ScalarType Metric(const Self * other) const;
00359 
00363   ScalarType Metric(void) const;
00364 
00366   void PrintSelf(std::ostream &s, Indent indent) const;
00367 
00374   const JacobianType & GetJacobian(const InputPointType  &point ) const;
00375 
00376 protected:
00384   AffineTransform(const MatrixType &matrix, const OutputVectorType &offset);
00385   AffineTransform();      
00386   
00388   virtual ~AffineTransform();
00389 
00391   void RecomputeInverse();
00392 
00393 private:
00394   AffineTransform(const Self & other);
00395   const Self & operator=( const Self & );
00396 
00397   MatrixType         m_Matrix;       // Matrix of the transformation
00398   OffsetType         m_Offset;       // Offset of the transformation
00399   MatrixType         m_Inverse;      // Inverse of the matrix
00400   bool               m_Singular;     // Is m_Inverse singular?
00401 
00402 
00403 }; //class AffineTransform
00404 
00405 }  // namespace itk
00406 
00407 
00408 #ifndef ITK_MANUAL_INSTANTIATION
00409 #include "itkAffineTransform.txx"
00410 #endif
00411 
00412 #endif /* __itkAffineTransform_h */
00413 
00414 
00415 
00416 
00417 

Generated at Wed Mar 12 01:12:46 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000