ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkRigid2DTransform.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkRigid2DTransform_h
19 #define __itkRigid2DTransform_h
20 
21 #include <iostream>
23 
24 namespace itk
25 {
56 template< typename TScalar = double >
57 // Data type for scalars (float or double)
59  public MatrixOffsetTransformBase< TScalar, 2, 2 > // Dimensions of
60  // input and output
61  // spaces
62 {
63 public:
69 
72 
74  itkNewMacro(Self);
75 
77  itkStaticConstMacro(InputSpaceDimension, unsigned int, 2);
78  itkStaticConstMacro(OutputSpaceDimension, unsigned int, 2);
79  itkStaticConstMacro(ParametersDimension, unsigned int, 3);
81 
84 
88 
91 
92  // / Standard matrix type for this class
95 
96  // / Standard vector type for this class
99 
100  // / Standard vector type for this class
104 
105  // / Standard covariant vector type for this class
108 
109  // / Standard vnl_vector type for this class
112 
113  // / Standard coordinate point type for this class
116 
120  typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer;
121 
134  virtual void SetMatrix(const MatrixType & matrix);
135 
143  void Translate(const OffsetType & offset, bool pre = false);
144 
153  inline InputPointType BackTransform(const OutputPointType & point) const;
154 
155  inline InputVectorType BackTransform(const OutputVectorType & vector) const;
156 
157  inline InputVnlVectorType BackTransform(const OutputVnlVectorType & vector) const;
158 
160 
162  void SetAngle(TScalar angle);
163 
164  itkGetConstReferenceMacro(Angle, TScalar);
165 
167  void SetAngleInDegrees(TScalar angle);
168 
172  void SetRotation(TScalar angle)
173  {
174  this->SetAngle(angle);
175  }
176  virtual const TScalar & GetRotation() const
177  {
178  return m_Angle;
179  }
181 
190  void SetParameters(const ParametersType & parameters);
191 
200  const ParametersType & GetParameters(void) const;
201 
204  virtual void ComputeJacobianWithRespectToParameters( const InputPointType & p, JacobianType & jacobian) const;
205 
210  void CloneInverseTo(Pointer & newinverse) const;
211 
213  bool GetInverse(Self *inverse) const;
214 
217 
222  void CloneTo(Pointer & clone) const;
223 
225  virtual void SetIdentity(void);
226 
227 #ifdef ITKV3_COMPATIBILITY
228 
234  itkLegacyMacro(virtual void SetRotationMatrix(const MatrixType & matrix));
235  itkLegacyMacro(const MatrixType & GetRotationMatrix() const);
236 #endif
237 
238 
239 protected:
240  Rigid2DTransform(unsigned int outputSpaceDimension, unsigned int parametersDimension);
241  Rigid2DTransform(unsigned int parametersDimension);
243 
245 
249  void PrintSelf(std::ostream & os, Indent indent) const;
250 
254  virtual void ComputeMatrix(void);
255 
260  virtual void ComputeMatrixParameters(void);
261 
263  void SetVarAngle(TScalar angle)
264  {
265  m_Angle = angle;
266  }
267 
268 private:
269  Rigid2DTransform(const Self &); // purposely not implemented
270  void operator=(const Self &); // purposely not implemented
271 
272  TScalar m_Angle;
273 
274 }; // class Rigid2DTransform
275 
276 // Back transform a point
277 template <typename TScalar>
278 inline
281 {
282  itkWarningMacro(
283  <<
284  "BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() to generate an inverse transform and then perform the transform using that inverted transform."
285  );
286  return this->GetInverseMatrix() * ( point - this->GetOffset() );
287 }
288 
289 // Back transform a vector
290 template <typename TScalar>
291 inline
294 {
295  itkWarningMacro(
296  <<
297  "BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() to generate an inverse transform and then perform the transform using that inverted transform."
298  );
299  return this->GetInverseMatrix() * vect;
300 }
301 
302 // Back transform a vnl_vector
303 template <typename TScalar>
304 inline
307 {
308  itkWarningMacro(
309  <<
310  "BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() to generate an inverse transform and then perform the transform using that inverted transform."
311  );
312  return this->GetInverseMatrix() * vect;
313 }
314 
315 // Back Transform a CovariantVector
316 template <typename TScalar>
317 inline
320 {
321  itkWarningMacro(
322  <<
323  "BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() to generate an inverse transform and then perform the transform using that inverted transform."
324  );
325  return this->GetMatrix() * vect;
326 }
327 
328 } // namespace itk
329 
330 #ifndef ITK_MANUAL_INSTANTIATION
331 #include "itkRigid2DTransform.hxx"
332 #endif
333 
334 #endif /* __itkRigid2DTransform_h */
Superclass::InverseTransformBaseType InverseTransformBaseType
static const unsigned int ParametersDimension
Light weight base class for most itk classes.
Vector< TScalar, itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType
Superclass::OffsetValueType OffsetValueType
void SetAngleInDegrees(TScalar angle)
static const unsigned int OutputSpaceDimension
Superclass::MatrixType MatrixType
virtual InverseTransformBasePointer GetInverseTransform() const
Matrix and Offset transformation of a vector space (e.g. space coordinates)
Superclass::OutputPointType OutputPointType
vnl_vector_fixed< TScalar, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVnlVectorType
virtual void SetIdentity(void)
static const unsigned int InputSpaceDimension
const ParametersType & GetParameters(void) const
Superclass::OutputVnlVectorType OutputVnlVectorType
void operator=(const Self &)
Matrix< TScalar, itkGetStaticConstMacro(OutputSpaceDimension), itkGetStaticConstMacro(InputSpaceDimension)> MatrixType
Superclass::InverseTransformBaseType InverseTransformBaseType
Superclass::JacobianType JacobianType
Superclass::ParametersValueType ParametersValueType
Superclass::OutputCovariantVectorType OutputCovariantVectorType
Vector< TScalar, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType
void SetRotation(TScalar angle)
Superclass::ScalarType ScalarType
Superclass::OutputVectorValueType OutputVectorValueType
SmartPointer< const Self > ConstPointer
vnl_vector_fixed< TScalar, itkGetStaticConstMacro(InputSpaceDimension)> InputVnlVectorType
Superclass::InputCovariantVectorType InputCovariantVectorType
bool GetInverse(Self *inverse) const
Point< TScalar, itkGetStaticConstMacro(InputSpaceDimension)> InputPointType
CovariantVector< TScalar, itkGetStaticConstMacro(OutputSpaceDimension)> OutputCovariantVectorType
Superclass::InputVectorType InputVectorType
Superclass::ParametersType ParametersType
Superclass::InputVnlVectorType InputVnlVectorType
virtual void ComputeMatrix(void)
void Translate(const OffsetType &offset, bool pre=false)
InverseTransformBaseType::Pointer InverseTransformBasePointer
Point< TScalar, itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType
void SetParameters(const ParametersType &parameters)
Superclass::OutputVectorType OutputVectorType
void CloneInverseTo(Pointer &newinverse) const
SmartPointer< Self > Pointer
CovariantVector< TScalar, itkGetStaticConstMacro(InputSpaceDimension)> InputCovariantVectorType
Rigid2DTransform of a vector space (e.g. space coordinates)
MatrixOffsetTransformBase< TScalar, 2, 2 > Superclass
virtual const TScalar & GetRotation() const
Superclass::InputPointType InputPointType
void PrintSelf(std::ostream &os, Indent indent) const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
void SetVarAngle(TScalar angle)
Superclass::OffsetType OffsetType
virtual void ComputeJacobianWithRespectToParameters(const InputPointType &p, JacobianType &jacobian) const
virtual void ComputeMatrixParameters(void)
InputPointType BackTransform(const OutputPointType &point) const
virtual void SetMatrix(const MatrixType &matrix)
void SetAngle(TScalar angle)
Superclass::MatrixValueType MatrixValueType
void CloneTo(Pointer &clone) const