ITK  4.13.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 
22 
23 namespace itk
24 {
55 template<typename TParametersValueType=double>
56 class ITK_TEMPLATE_EXPORT Rigid2DTransform :
57  public MatrixOffsetTransformBase<TParametersValueType, 2, 2>
58 {
59 public:
65 
68 
70  itkNewMacro(Self);
71 
73  itkStaticConstMacro(InputSpaceDimension, unsigned int, 2);
74  itkStaticConstMacro(OutputSpaceDimension, unsigned int, 2);
75  itkStaticConstMacro(ParametersDimension, unsigned int, 3);
77 
79  typedef typename Superclass::ScalarType ScalarType;
80 
82  typedef typename Superclass::ParametersType ParametersType;
83  typedef typename Superclass::ParametersValueType ParametersValueType;
84  typedef typename Superclass::FixedParametersType FixedParametersType;
85  typedef typename Superclass::FixedParametersValueType FixedParametersValueType;
86 
88  typedef typename Superclass::JacobianType JacobianType;
89 
90  // / Standard matrix type for this class
91  typedef typename Superclass::MatrixType MatrixType;
92  typedef typename Superclass::MatrixValueType MatrixValueType;
93 
94  // / Standard vector type for this class
95  typedef typename Superclass::OffsetType OffsetType;
97 
98  // / Standard vector type for this class
99  typedef typename Superclass::InputVectorType InputVectorType;
100  typedef typename Superclass::OutputVectorType OutputVectorType;
101  typedef typename Superclass::OutputVectorValueType OutputVectorValueType;
102 
103  // / Standard covariant vector type for this class
104  typedef typename Superclass::InputCovariantVectorType InputCovariantVectorType;
105  typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType;
106 
107  // / Standard vnl_vector type for this class
108  typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
109  typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
110 
111  // / Standard coordinate point type for this class
112  typedef typename Superclass::InputPointType InputPointType;
113  typedef typename Superclass::OutputPointType OutputPointType;
114 
117  typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType;
118  typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer;
119 
132  virtual void SetMatrix(const MatrixType & matrix) ITK_OVERRIDE;
133 
146  virtual void SetMatrix(const MatrixType & matrix, const TParametersValueType tolerance);
147 
155  void Translate(const OffsetType & offset, bool pre = false);
156 
165  inline InputPointType BackTransform(const OutputPointType & point) const;
166 
167  inline InputVectorType BackTransform(const OutputVectorType & vector) const;
168 
169  inline InputVnlVectorType BackTransform(const OutputVnlVectorType & vector) const;
170 
171  inline InputCovariantVectorType BackTransform(const OutputCovariantVectorType & vector) const;
172 
174  void SetAngle(TParametersValueType angle);
175 
176  itkGetConstReferenceMacro(Angle, TParametersValueType);
177 
179  void SetAngleInDegrees(TParametersValueType angle);
180 
184  void SetRotation(TParametersValueType angle)
185  {
186  this->SetAngle(angle);
187  }
188  virtual const TParametersValueType & GetRotation() const
189  {
190  return m_Angle;
191  }
193 
202  virtual void SetParameters(const ParametersType & parameters) ITK_OVERRIDE;
203 
212  virtual const ParametersType & GetParameters() const ITK_OVERRIDE;
213 
216  virtual void ComputeJacobianWithRespectToParameters(const InputPointType & p, JacobianType & jacobian) const ITK_OVERRIDE;
217 
222  void CloneInverseTo(Pointer & newinverse) const;
223 
225  bool GetInverse(Self *inverse) const;
226 
228  virtual InverseTransformBasePointer GetInverseTransform() const ITK_OVERRIDE;
229 
234  void CloneTo(Pointer & clone) const;
235 
237  virtual void SetIdentity() ITK_OVERRIDE;
238 
239 #ifdef ITKV3_COMPATIBILITY
240 
246  itkLegacyMacro(virtual void SetRotationMatrix(const MatrixType & matrix));
247  itkLegacyMacro(const MatrixType & GetRotationMatrix() const);
248 #endif
249 
250 
251 protected:
252  Rigid2DTransform(unsigned int outputSpaceDimension, unsigned int parametersDimension);
253  Rigid2DTransform(unsigned int parametersDimension);
255 
256  ~Rigid2DTransform() ITK_OVERRIDE;
257 
261  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
262 
266  virtual void ComputeMatrix() ITK_OVERRIDE;
267 
272  virtual void ComputeMatrixParameters() ITK_OVERRIDE;
273 
275  void SetVarAngle(TParametersValueType angle)
276  {
277  m_Angle = angle;
278  }
279 
280 private:
281  ITK_DISALLOW_COPY_AND_ASSIGN(Rigid2DTransform);
282 
283  TParametersValueType m_Angle;
284 
285 }; // class Rigid2DTransform
286 
287 // Back transform a point
288 template<typename TParametersValueType>
289 inline
292 {
293  itkWarningMacro(
294  <<
295  "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."
296  );
297  return this->GetInverseMatrix() * ( point - this->GetOffset() );
298 }
299 
300 // Back transform a vector
301 template<typename TParametersValueType>
302 inline
305 {
306  itkWarningMacro(
307  <<
308  "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."
309  );
310  return this->GetInverseMatrix() * vect;
311 }
312 
313 // Back transform a vnl_vector
314 template<typename TParametersValueType>
315 inline
318 {
319  itkWarningMacro(
320  <<
321  "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."
322  );
323  return this->GetInverseMatrix() * vect;
324 }
325 
326 // Back Transform a CovariantVector
327 template<typename TParametersValueType>
328 inline
331 {
332  itkWarningMacro(
333  <<
334  "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."
335  );
336  return this->GetMatrix() * vect;
337 }
338 
339 } // namespace itk
340 
341 #ifndef ITK_MANUAL_INSTANTIATION
342 #include "itkRigid2DTransform.hxx"
343 #endif
344 
345 #endif /* itkRigid2DTransform_h */
Superclass::MatrixValueType MatrixValueType
Light weight base class for most itk classes.
InverseTransformBaseType::Pointer InverseTransformBasePointer
void SetRotation(TParametersValueType angle)
signed long OffsetValueType
Definition: itkIntTypes.h:154
Superclass::InputPointType InputPointType
Matrix and Offset transformation of a vector space (e.g. space coordinates)
Superclass::OutputVnlVectorType OutputVnlVectorType
Superclass::InputCovariantVectorType InputCovariantVectorType
Superclass::ParametersType ParametersType
Superclass::OutputVectorValueType OutputVectorValueType
Superclass::FixedParametersValueType FixedParametersValueType
Superclass::JacobianType JacobianType
InputPointType BackTransform(const OutputPointType &point) const
MatrixOffsetTransformBase< TParametersValueType, 2, 2 > Superclass
Superclass::InputVnlVectorType InputVnlVectorType
TParametersValueType m_Angle
Superclass::OutputVectorType OutputVectorType
Superclass::OutputCovariantVectorType OutputCovariantVectorType
Superclass::FixedParametersType FixedParametersType
virtual const TParametersValueType & GetRotation() const
SmartPointer< const Self > ConstPointer
Superclass::OutputPointType OutputPointType
Rigid2DTransform of a vector space (e.g. space coordinates)
SmartPointer< Self > Pointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Superclass::InputVectorType InputVectorType
Superclass::MatrixType MatrixType
Superclass::ParametersValueType ParametersValueType
Superclass::OffsetType OffsetType
Superclass::ScalarType ScalarType
Superclass::InverseTransformBaseType InverseTransformBaseType
Superclass::OffsetValueType OffsetValueType