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: 2003/09/10 14:29:00 $ 00007 Version: $Revision: 1.52 $ 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 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 00108 template < 00109 class TScalarType=double, // Data type for scalars (e.g. float or double) 00110 unsigned int NDimensions=3> // Number of dimensions in the input space 00111 class AffineTransform : public Transform< TScalarType, 00112 NDimensions, 00113 NDimensions > 00114 { 00115 public: 00117 typedef AffineTransform Self; 00118 typedef Transform< TScalarType, NDimensions, NDimensions > Superclass; 00119 typedef SmartPointer<Self> Pointer; 00120 typedef SmartPointer<const Self> ConstPointer; 00121 00123 itkTypeMacro( AffineTransform, Transform ); 00124 00126 itkNewMacro( Self ); 00127 00129 itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions); 00130 itkStaticConstMacro(ParametersDimension, unsigned int, 00131 NDimensions*(NDimensions+1)); 00132 00133 00135 typedef typename Superclass::ParametersType ParametersType; 00136 00138 typedef typename Superclass::JacobianType JacobianType; 00139 00141 typedef typename Superclass::ScalarType ScalarType; 00142 00144 typedef Vector<TScalarType, 00145 itkGetStaticConstMacro(SpaceDimension)> InputVectorType; 00146 typedef Vector<TScalarType, 00147 itkGetStaticConstMacro(SpaceDimension)> OutputVectorType; 00148 00150 typedef CovariantVector<TScalarType, 00151 itkGetStaticConstMacro(SpaceDimension)> InputCovariantVectorType; 00152 typedef CovariantVector<TScalarType, 00153 itkGetStaticConstMacro(SpaceDimension)> OutputCovariantVectorType; 00154 00156 typedef vnl_vector_fixed<TScalarType, 00157 itkGetStaticConstMacro(SpaceDimension)> InputVnlVectorType; 00158 typedef vnl_vector_fixed<TScalarType, 00159 itkGetStaticConstMacro(SpaceDimension)> OutputVnlVectorType; 00160 00162 typedef Point<TScalarType, 00163 itkGetStaticConstMacro(SpaceDimension)> InputPointType; 00164 typedef Point<TScalarType, 00165 itkGetStaticConstMacro(SpaceDimension)> OutputPointType; 00166 00168 typedef Matrix<TScalarType, itkGetStaticConstMacro(SpaceDimension), 00169 itkGetStaticConstMacro(SpaceDimension)> MatrixType; 00170 00172 typedef OutputVectorType OffsetType; 00173 00177 const OffsetType & GetOffset(void) const 00178 { return m_Offset; } 00179 00184 const MatrixType & GetMatrix() const 00185 { return m_Matrix; } 00186 00190 void SetIdentity( void ) 00191 { m_Matrix.SetIdentity(); 00192 m_Offset.Fill( 0.0 ); 00193 this->RecomputeInverse(); 00194 this->Modified(); 00195 } 00196 00204 const MatrixType & GetInverse() const 00205 { if( m_Singular ) { throw ExceptionObject(__FILE__, __LINE__); } 00206 return m_Inverse; 00207 } 00208 00214 void SetOffset(const OffsetType &offset) 00215 { m_Offset = offset; this->Modified(); return; } 00216 00221 void SetMatrix(const MatrixType &matrix) 00222 { m_Matrix = matrix; RecomputeInverse(); this->Modified(); return; } 00223 00227 void SetParameters( const ParametersType & parameters ); 00228 00230 const ParametersType& GetParameters(void) const; 00231 00242 void Compose(const Self * other, bool pre=0); 00243 00249 void Translate(const OutputVectorType &offset, bool pre=0); 00250 00261 void Scale(const OutputVectorType &factor, bool pre=0); 00262 void Scale(const TScalarType &factor, bool pre=0); 00263 00278 void Rotate(int axis1, int axis2, TScalarType angle, bool pre=0); 00279 00292 void Rotate2D(TScalarType angle, bool pre=0); 00293 00306 void Rotate3D(const OutputVectorType &axis, TScalarType angle, bool pre=0); 00307 00317 void Shear(int axis1, int axis2, TScalarType coef, bool pre=0); 00318 00326 OutputPointType TransformPoint (const InputPointType &point ) const; 00327 OutputVectorType TransformVector(const InputVectorType &vector) const; 00328 OutputVnlVectorType TransformVector(const InputVnlVectorType &vector) const; 00329 OutputCovariantVectorType TransformCovariantVector( 00330 const InputCovariantVectorType &vector) const; 00331 00337 inline InputPointType BackTransform(const OutputPointType &point ) const; 00338 inline InputVectorType BackTransform(const OutputVectorType &vector) const; 00339 inline InputVnlVectorType BackTransform(const OutputVnlVectorType &vector) const; 00340 00341 inline InputCovariantVectorType BackTransform( 00342 const OutputCovariantVectorType &vector) const; 00343 00350 InputPointType BackTransformPoint(const OutputPointType &point) const; 00351 00357 typename AffineTransform::Pointer Inverse(void) const; 00358 00370 ScalarType Metric(const Self * other) const; 00371 00375 ScalarType Metric(void) const; 00376 00383 const JacobianType & GetJacobian(const InputPointType &point ) const; 00384 00385 protected: 00393 AffineTransform(const MatrixType &matrix, const OutputVectorType &offset); 00394 AffineTransform(unsigned int outputSpaceDimension, unsigned int parametersDimension); 00395 AffineTransform(); 00396 00398 virtual ~AffineTransform(); 00399 00401 void RecomputeInverse(); 00402 00404 void PrintSelf(std::ostream &s, Indent indent) const; 00405 00406 private: 00407 AffineTransform(const Self & other); 00408 const Self & operator=( const Self & ); 00409 00410 MatrixType m_Matrix; // Matrix of the transformation 00411 OffsetType m_Offset; // Offset of the transformation 00412 MatrixType m_Inverse; // Inverse of the matrix 00413 bool m_Singular; // Is m_Inverse singular? 00414 00415 00416 }; //class AffineTransform 00417 00418 } // namespace itk 00419 00420 00421 #ifndef ITK_MANUAL_INSTANTIATION 00422 #include "itkAffineTransform.txx" 00423 #endif 00424 00425 #endif /* __itkAffineTransform_h */ 00426 00427 00428 00429 00430

Generated at Sat Mar 31 02:13:56 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000