ITK  4.8.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>
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 
80 
86 
89 
90  // / Standard matrix type for this class
93 
94  // / Standard vector type for this class
97 
98  // / Standard vector type for this class
102 
103  // / Standard covariant vector type for this class
106 
107  // / Standard vnl_vector type for this class
110 
111  // / Standard coordinate point type for this class
114 
118  typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer;
119 
132  virtual void SetMatrix(const MatrixType & matrix) ITK_OVERRIDE;
133 
146  virtual void SetMatrix(const MatrixType & matrix, double 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 
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 
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  Rigid2DTransform(const Self &); // purposely not implemented
282  void operator=(const Self &); // purposely not implemented
283 
284  TParametersValueType m_Angle;
285 
286 }; // class Rigid2DTransform
287 
288 // Back transform a point
289 template<typename TParametersValueType>
290 inline
293 {
294  itkWarningMacro(
295  <<
296  "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."
297  );
298  return this->GetInverseMatrix() * ( point - this->GetOffset() );
299 }
300 
301 // Back transform a vector
302 template<typename TParametersValueType>
303 inline
306 {
307  itkWarningMacro(
308  <<
309  "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."
310  );
311  return this->GetInverseMatrix() * vect;
312 }
313 
314 // Back transform a vnl_vector
315 template<typename TParametersValueType>
316 inline
319 {
320  itkWarningMacro(
321  <<
322  "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."
323  );
324  return this->GetInverseMatrix() * vect;
325 }
326 
327 // Back Transform a CovariantVector
328 template<typename TParametersValueType>
329 inline
332 {
333  itkWarningMacro(
334  <<
335  "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."
336  );
337  return this->GetMatrix() * vect;
338 }
339 
340 } // namespace itk
341 
342 #ifndef ITK_MANUAL_INSTANTIATION
343 #include "itkRigid2DTransform.hxx"
344 #endif
345 
346 #endif /* itkRigid2DTransform_h */
void SetAngleInDegrees(TParametersValueType angle)
Point< TParametersValueType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType
virtual void SetMatrix(const MatrixType &matrix) override
CovariantVector< TParametersValueType, itkGetStaticConstMacro(InputSpaceDimension)> InputCovariantVectorType
Superclass::MatrixValueType MatrixValueType
Matrix< TParametersValueType, itkGetStaticConstMacro(OutputSpaceDimension), itkGetStaticConstMacro(InputSpaceDimension)> MatrixType
Light weight base class for most itk classes.
InverseTransformBaseType::Pointer InverseTransformBasePointer
void SetRotation(TParametersValueType angle)
virtual void ComputeMatrix() override
Superclass::InputPointType InputPointType
CovariantVector< TParametersValueType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputCovariantVectorType
Matrix and Offset transformation of a vector space (e.g. space coordinates)
Superclass::OutputVnlVectorType OutputVnlVectorType
void SetAngle(TParametersValueType angle)
static const unsigned int OutputSpaceDimension
vnl_vector_fixed< TParametersValueType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVnlVectorType
Superclass::InputCovariantVectorType InputCovariantVectorType
void CloneInverseTo(Pointer &newinverse) const
Superclass::ParametersType ParametersType
Superclass::OutputVectorValueType OutputVectorValueType
void CloneTo(Pointer &clone) const
static const unsigned int ParametersDimension
Superclass::FixedParametersValueType FixedParametersValueType
Superclass::JacobianType JacobianType
virtual void PrintSelf(std::ostream &os, Indent indent) const override
InputPointType BackTransform(const OutputPointType &point) const
MatrixOffsetTransformBase< TParametersValueType, 2, 2 > Superclass
bool GetInverse(Self *inverse) const
Superclass::InputVnlVectorType InputVnlVectorType
TParametersValueType m_Angle
static const unsigned int InputSpaceDimension
void operator=(const Self &)
virtual const ParametersType & GetParameters() const override
Superclass::OutputVectorType OutputVectorType
virtual InverseTransformBasePointer GetInverseTransform() const override
Superclass::OutputCovariantVectorType OutputCovariantVectorType
Superclass::FixedParametersType FixedParametersType
virtual const TParametersValueType & GetRotation() const
Vector< TParametersValueType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType
virtual void SetIdentity() override
SmartPointer< const Self > ConstPointer
virtual void SetParameters(const ParametersType &parameters) override
Superclass::OutputPointType OutputPointType
Rigid2DTransform of a vector space (e.g. space coordinates)
virtual void ComputeJacobianWithRespectToParameters(const InputPointType &p, JacobianType &jacobian) const override
SmartPointer< Self > Pointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Superclass::InputVectorType InputVectorType
vnl_vector_fixed< TParametersValueType, itkGetStaticConstMacro(InputSpaceDimension)> InputVnlVectorType
Superclass::MatrixType MatrixType
virtual void ComputeMatrixParameters() override
void SetVarAngle(TParametersValueType angle)
Superclass::ParametersValueType ParametersValueType
Point< TParametersValueType, itkGetStaticConstMacro(InputSpaceDimension)> InputPointType
Superclass::OffsetType OffsetType
Superclass::ScalarType ScalarType
Superclass::InverseTransformBaseType InverseTransformBaseType
void Translate(const OffsetType &offset, bool pre=false)
Vector< TParametersValueType, itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType
Superclass::OffsetValueType OffsetValueType