KWStyle - itkRigid2DTransform.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkRigid2DTransform.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:47 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17 #ifndef __itkRigid2DTransform_h
18 #define __itkRigid2DTransform_h
19
20 #include <iostream>
21 #include "itkMatrixOffsetTransformBase.h"
22 #include "itkExceptionObject.h"
23
24 namespace itk
25 {
26
27 /** \brief Rigid2DTransform of a vector space (e.g. space coordinates)
28  *
29  * This transform applies a rigid transformation in 2D space.
30  * The transform is specified as a rotation around a arbitrary center
31  * and is followed by a translation.
32  *
33  * The parameters for this transform can be set either using
34  * individual Set methods or in serialized form using
35  * SetParameters() and SetFixedParameters().
36  *
37  * The serialization of the optimizable parameters is an array of 3 elements
38  * ordered as follows:
39  * p[0] = angle
40  * p[1] = x component of the translation
41  * p[2] = y component of the translation
42  *
43  * The serialization of the fixed parameters is an array of 2 elements
44  * ordered as follows:
45  * p[0] = x coordinate of the center
46  * p[1] = y coordinate of the center
47  *
48  * Access methods for the center, translation and underlying matrix
49  * offset vectors are documented in the superclass MatrixOffsetTransformBase.
50  *
51  * \sa Transfrom
52  * \sa MatrixOffsetTransformBase
53  *
54  * \ingroup Transforms
55  */
56 LEN template < class TScalarType=double >    // Data type for scalars (float or double)
57 MCM class ITK_EXPORT Rigid2DTransform : 
58 LEN,IND ********public MatrixOffsetTransformBase< TScalarType, 2, 2> // Dimensions of input and output spaces
59 {
60 public:
61   /** Standard class typedefs. */
62   typedef Rigid2DTransform Self;
63 TDA   typedef MatrixOffsetTransformBase< TScalarType, 2, 2 > Superclass;
64 TDA   typedef SmartPointer<Self>        Pointer;
65 TDA   typedef SmartPointer<const Self>  ConstPointer;
66   
67   /** Run-time type information (and related methods). */
68   itkTypeMacro( Rigid2DTransform, MatrixOffsetTransformBase );
69
70   /** New macro for creation of through a Smart Pointer */
71   itkNewMacro( Self );
72
73   /** Dimension of the space. */
74   itkStaticConstMacro(InputSpaceDimension, unsigned int, 2);
75   itkStaticConstMacro(OutputSpaceDimension, unsigned int, 2);
76   itkStaticConstMacro(ParametersDimension, unsigned int, 3);
77
78   /** Scalar type. */
79   typedef typename Superclass::ScalarType  ScalarType;
80
81   /** Parameters type. */
82   typedef typename Superclass::ParametersType  ParametersType;
83
84   /** Jacobian type. */
85   typedef typename Superclass::JacobianType  JacobianType;
86
87   /// Standard matrix type for this class
88   typedef typename Superclass::MatrixType MatrixType;
89
90   /// Standard vector type for this class
91   typedef typename Superclass::OffsetType OffsetType;
92
93   /// Standard vector type for this class
94   typedef typename Superclass::InputVectorType InputVectorType;
95 TDA   typedef typename Superclass::OutputVectorType OutputVectorType;
96
97   /// Standard covariant vector type for this class
98 LEN   typedef typename Superclass::InputCovariantVectorType InputCovariantVectorType;
99 LEN,TDA   typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType;
100
101   /// Standard vnl_vector type for this class
102   typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
103 TDA   typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
104
105   /// Standard coordinate point type for this class
106   typedef typename Superclass::InputPointType    InputPointType;
107 TDA   typedef typename Superclass::OutputPointType    OutputPointType;
108
109   /**
110    * Set the rotation Matrix of a Rigid2D Transform
111    *
112    * This method sets the 2x2 matrix representing the rotation
113    * in the transform.  The Matrix is expected to be orthogonal
114    * with a certain tolerance.
115    *
116    * \warning This method will throw an exception is the matrix
117    * provided as argument is not orthogonal.
118    *
119    * \sa MatrixOffsetTransformBase::SetMatrix()
120    **/
121   virtual void SetMatrix( const MatrixType & matrix );
122
123   /**
124    * Set/Get the rotation matrix. These methods are old and are
125    * retained for backward compatibility. Instead, use SetMatrix()
126    * GetMatrix().
127    **/
128   virtual void SetRotationMatrix(const MatrixType &matrix)
129     { this->SetMatrix( matrix ); }
130 IND ***const MatrixType & GetRotationMatrix() const
131     { return this->GetMatrix(); }
132
133
134   /**
135    * Compose the transformation with a translation
136    *
137    * This method modifies self to include a translation of the
138    * origin.  The translation is precomposed with self if pre is
139    * true, and postcomposed otherwise.
140    **/
141   void Translate(const OffsetType &offset, bool pre=false);
142
143   /**
144    * Back transform by an rigid transformation.
145    *
146    * The BackTransform() methods are slated to be removed from ITK.  
147    * Instead, please use GetInverse() or CloneInverseTo() to generate 
148    * an inverse transform and  then perform the transform using that 
149    * inverted transform.
150    **/
151 LEN   inline InputPointType      BackTransform(const OutputPointType  &point ) const;
152 LEN   inline InputVectorType     BackTransform(const OutputVectorType &vector) const;
153 LEN   inline InputVnlVectorType  BackTransform(const OutputVnlVectorType &vector) const;
154
155   inline InputCovariantVectorType BackTransform(
156 LEN                                      const OutputCovariantVectorType &vector) const;
157
158   /** Set/Get the angle of rotation in radians */
159   void SetAngle(TScalarType angle);
160   itkGetConstReferenceMacro( Angle, TScalarType );
161
162   /** Set the angle of rotation in degrees. */
163   void SetAngleInDegrees(TScalarType angle);
164
165   /** Set/Get the angle of rotation in radians. These methods
166    * are old and are retained for backward compatibility.
167    * Instead, use SetAngle() and GetAngle(). */
168   void SetRotation(TScalarType angle)
169     { this->SetAngle(angle); }
170   virtual const TScalarType & GetRotation() const
171     { return m_Angle; }  
172
173   /** Set the transformation from a container of parameters
174    * This is typically used by optimizers.
175    * There are 3 parameters. The first one represents the
176    * angle of rotation in radians and the last two represents the translation.
177    * The center of rotation is fixed.
178    * 
179    * \sa Transform::SetParameters()
180    * \sa Transform::SetFixedParameters() */
181   void SetParameters( const ParametersType & parameters );
182
183   /** Get the parameters that uniquely define the transform
184    * This is typically used by optimizers.
185    * There are 3 parameters. The first one represents the
186    * angle or rotation in radians and the last two represents the translation. 
187    * The center of rotation is fixed.
188    *
189    * \sa Transform::GetParameters()
190    * \sa Transform::GetFixedParameters() */
191   const ParametersType & GetParameters( void ) const;
192   
193   /** This method computes the Jacobian matrix of the transformation
194    * at a given input point.
195    *
196    * \sa Transform::GetJacobian() */
197   const JacobianType & GetJacobian(const InputPointType  &point ) const;
198
199   /**
200    * This method creates and returns a new Rigid2DTransform object
201    * which is the inverse of self.
202    **/
203   void CloneInverseTo( Pointer & newinverse ) const;
204
205   /**
206    * This method creates and returns a new Rigid2DTransform object
207    * which has the same parameters.
208    **/
209   void CloneTo( Pointer & clone ) const;
210
211   /** Reset the parameters to create and identity transform. */
212   virtual void SetIdentity(void);
213
214 protected:
215   Rigid2DTransform();
216   Rigid2DTransform( unsigned int outputSpaceDimension, 
217                     unsigned int parametersDimension);
218  
219 IND *~Rigid2DTransform();
220  
221 IND */**
222    * Print contents of an Rigid2DTransform
223    **/
224   void PrintSelf(std::ostream &os, Indent indent) const;
225
226   /** Compute the matrix from angle. This is used in Set methods
227    * to update the underlying matrix whenever a transform parameter 
228    * is changed. */
229   virtual void ComputeMatrix(void);
230
231   /** Compute the angle from the matrix. This is used to compute
232    * transform parameters from a given matrix. This is used in
233    * MatrixOffsetTransformBase::Compose() and 
234    * MatrixOffsetTransformBase::GetInverse(). */
235   virtual void ComputeMatrixParameters(void);
236
237   /** Update angle without recomputation of other internal variables. */
238   void SetVarAngle( TScalarType angle )
239     { m_Angle = angle; }
240
241 private:
242   Rigid2DTransform(const Self&); //purposely not implemented
243   void operator=(const Self&); //purposely not implemented
244   
245   TScalarType         m_Angle; 
246
247 }; //class Rigid2DTransform
248
249
250 }  // namespace itk
251
252
253 #ifndef ITK_MANUAL_INSTANTIATION
254 #include "itkRigid2DTransform.txx"
255 #endif
256
257 #endif /* __itkRigid2DTransform_h */
258

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:41PM
© Kitware Inc.