00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkRigid2DTransform_h
00018 #define __itkRigid2DTransform_h
00019
00020 #include <iostream>
00021 #include "itkTransform.h"
00022 #include "itkExceptionObject.h"
00023 #include "itkMatrix.h"
00024
00025 namespace itk
00026 {
00027
00034 template < class TScalarType=double >
00035 class ITK_EXPORT Rigid2DTransform :
00036 public Transform< TScalarType, 2, 2>
00037 {
00038 public:
00040 typedef Rigid2DTransform Self;
00041 typedef Transform< TScalarType, 2, 2 > Superclass;
00042 typedef SmartPointer<Self> Pointer;
00043 typedef SmartPointer<const Self> ConstPointer;
00044
00046 itkTypeMacro( Rigid2DTransform, Transform );
00047
00049 itkNewMacro( Self );
00050
00052 itkStaticConstMacro(InputSpaceDimension, unsigned int, 2);
00053 itkStaticConstMacro(OutputSpaceDimension, unsigned int, 2);
00054 itkStaticConstMacro(ParametersDimension, unsigned int, 4);
00055
00057 typedef typename Superclass::ScalarType ScalarType;
00058
00060 typedef typename Superclass::ParametersType ParametersType;
00061
00063 typedef typename Superclass::JacobianType JacobianType;
00064
00066 typedef Matrix<ScalarType, itkGetStaticConstMacro(InputSpaceDimension), itkGetStaticConstMacro(InputSpaceDimension)> MatrixType;
00067
00069 typedef Vector<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> OffsetType;
00070
00072 typedef Vector<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType;
00073 typedef Vector<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType;
00074
00076 typedef CovariantVector<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputCovariantVectorType;
00077 typedef CovariantVector<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputCovariantVectorType;
00078
00080 typedef vnl_vector_fixed<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputVnlVectorType;
00081 typedef vnl_vector_fixed<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVnlVectorType;
00082
00084 typedef Point<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputPointType;
00085 typedef Point<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType;
00086
00093 itkGetConstReferenceMacro( Offset, OffsetType );
00094
00101 itkGetConstReferenceMacro( RotationMatrix, MatrixType );
00102
00109 const MatrixType & GetMatrix( )
00110 {
00111 return this->GetRotationMatrix();
00112 }
00113
00114
00121 itkSetMacro( Offset, OffsetType );
00122
00123
00133 virtual void SetRotationMatrix(const MatrixType &matrix);
00134
00144 void SetMatrix(const MatrixType &matrix)
00145 {
00146 this->SetRotationMatrix(matrix);
00147 }
00148
00153 virtual void Compose(const Self *other, bool pre=false);
00154
00155
00163 void Translate(const OffsetType &offset, bool pre=false);
00164
00165
00173 OutputPointType TransformPoint(const InputPointType &point ) const;
00174 OutputVectorType TransformVector(const InputVectorType &vector) const;
00175 OutputVnlVectorType TransformVector(const InputVnlVectorType &vector) const;
00176
00177 OutputCovariantVectorType TransformCovariantVector(
00178 const InputCovariantVectorType &vector) const;
00179
00187 inline InputPointType BackTransform(const OutputPointType &point ) const;
00188 inline InputVectorType BackTransform(const OutputVectorType &vector) const;
00189 inline InputVnlVectorType BackTransform(const OutputVnlVectorType &vector) const;
00190
00191 inline InputCovariantVectorType BackTransform(
00192 const OutputCovariantVectorType &vector) const;
00193
00194
00202 bool GetInverse(Self* inverse) const;
00203
00205 virtual void SetIdentity(void);
00206
00208 virtual const JacobianType & GetJacobian(const InputPointType &point ) const;
00209
00210
00211 protected:
00212 Rigid2DTransform();
00213 ~Rigid2DTransform();
00214
00215 Rigid2DTransform(unsigned int outputSpaceDimension, unsigned int parametersDimension);
00219 void PrintSelf(std::ostream &os, Indent indent) const;
00220
00221
00222
00223
00224
00225
00226 MatrixType m_RotationMatrix;
00227
00228
00229 mutable MatrixType m_InverseMatrix;
00230
00231
00232 MatrixType GetInverseMatrix() const;
00233
00234
00235 mutable TimeStamp m_InverseMatrixMTime;
00236 TimeStamp m_RotationMatrixMTime;
00237
00238 private:
00239 Rigid2DTransform(const Self&);
00240 void operator=(const Self&);
00241
00242
00243 OffsetType m_Offset;
00244
00245 };
00246
00247
00248 }
00249
00250
00251 #ifndef ITK_MANUAL_INSTANTIATION
00252 #include "itkRigid2DTransform.txx"
00253 #endif
00254
00255 #endif