ITK  5.0.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:
60  ITK_DISALLOW_COPY_AND_ASSIGN(Rigid2DTransform);
61 
67 
70 
72  itkNewMacro(Self);
73 
75  static constexpr unsigned int InputSpaceDimension = 2;
76  static constexpr unsigned int OutputSpaceDimension = 2;
77  static constexpr unsigned int ParametersDimension = 3;
78 
80  using ScalarType = typename Superclass::ScalarType;
81 
83  using ParametersType = typename Superclass::ParametersType;
84  using ParametersValueType = typename Superclass::ParametersValueType;
85  using FixedParametersType = typename Superclass::FixedParametersType;
86  using FixedParametersValueType = typename Superclass::FixedParametersValueType;
87 
89  using JacobianType = typename Superclass::JacobianType;
90  using JacobianPositionType = typename Superclass::JacobianPositionType;
91  using InverseJacobianPositionType = typename Superclass::InverseJacobianPositionType;
92 
93  // / Standard matrix type for this class
94  using MatrixType = typename Superclass::MatrixType;
95  using MatrixValueType = typename Superclass::MatrixValueType;
96 
97  // / Standard vector type for this class
98  using OffsetType = typename Superclass::OffsetType;
100 
101  // / Standard vector type for this class
102  using InputVectorType = typename Superclass::InputVectorType;
103  using OutputVectorType = typename Superclass::OutputVectorType;
104  using OutputVectorValueType = typename Superclass::OutputVectorValueType;
105 
106  // / Standard covariant vector type for this class
107  using InputCovariantVectorType = typename Superclass::InputCovariantVectorType;
108  using OutputCovariantVectorType = typename Superclass::OutputCovariantVectorType;
109 
110  // / Standard vnl_vector type for this class
111  using InputVnlVectorType = typename Superclass::InputVnlVectorType;
112  using OutputVnlVectorType = typename Superclass::OutputVnlVectorType;
113 
114  // / Standard coordinate point type for this class
115  using InputPointType = typename Superclass::InputPointType;
116  using OutputPointType = typename Superclass::OutputPointType;
117 
120  using InverseTransformBaseType = typename Superclass::InverseTransformBaseType;
121  using InverseTransformBasePointer = typename InverseTransformBaseType::Pointer;
122 
135  void SetMatrix(const MatrixType & matrix) override;
136 
149  virtual void SetMatrix(const MatrixType & matrix, const TParametersValueType tolerance);
150 
158  void Translate(const OffsetType & offset, bool pre = false);
159 
168  inline InputPointType BackTransform(const OutputPointType & point) const;
169 
170  inline InputVectorType BackTransform(const OutputVectorType & vector) const;
171 
172  inline InputVnlVectorType BackTransform(const OutputVnlVectorType & vector) const;
173 
174  inline InputCovariantVectorType BackTransform(const OutputCovariantVectorType & vector) const;
175 
177  void SetAngle(TParametersValueType angle);
178 
179  itkGetConstReferenceMacro(Angle, TParametersValueType);
180 
182  void SetAngleInDegrees(TParametersValueType angle);
183 
187  void SetRotation(TParametersValueType angle)
188  {
189  this->SetAngle(angle);
190  }
191  virtual const TParametersValueType & GetRotation() const
192  {
193  return m_Angle;
194  }
196 
205  void SetParameters(const ParametersType & parameters) override;
206 
215  const ParametersType & GetParameters() const override;
216 
219  void ComputeJacobianWithRespectToParameters(const InputPointType & p, JacobianType & jacobian) const override;
220 
225  void CloneInverseTo(Pointer & newinverse) const;
226 
228  bool GetInverse(Self *inverse) const;
229 
231  InverseTransformBasePointer GetInverseTransform() const override;
232 
237  void CloneTo(Pointer & clone) const;
238 
240  void SetIdentity() override;
241 
242 protected:
243  Rigid2DTransform(unsigned int outputSpaceDimension, unsigned int parametersDimension);
244  Rigid2DTransform(unsigned int parametersDimension);
246 
247  ~Rigid2DTransform() override = default;
248 
252  void PrintSelf(std::ostream & os, Indent indent) const override;
253 
257  void ComputeMatrix() override;
258 
263  void ComputeMatrixParameters() override;
264 
266  void SetVarAngle(TParametersValueType angle)
267  {
268  m_Angle = angle;
269  }
270 
271 private:
272  TParametersValueType m_Angle;
273 
274 }; // class Rigid2DTransform
275 
276 // Back transform a point
277 template<typename TParametersValueType>
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 TParametersValueType>
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 TParametersValueType>
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 TParametersValueType>
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 */
typename Superclass::OffsetValueType OffsetValueType
Light weight base class for most itk classes.
typename Superclass::InputPointType InputPointType
void SetRotation(TParametersValueType angle)
typename Superclass::ParametersType ParametersType
typename Superclass::InverseTransformBaseType InverseTransformBaseType
typename Superclass::InputVnlVectorType InputVnlVectorType
Matrix and Offset transformation of a vector space (e.g. space coordinates)
typename Superclass::FixedParametersValueType FixedParametersValueType
typename Superclass::MatrixType MatrixType
InputPointType BackTransform(const OutputPointType &point) const
typename Superclass::InputVectorType InputVectorType
typename Superclass::OutputPointType OutputPointType
typename Superclass::MatrixValueType MatrixValueType
TParametersValueType m_Angle
typename Superclass::JacobianType JacobianType
typename Superclass::ScalarType ScalarType
virtual const TParametersValueType & GetRotation() const
typename Superclass::OutputVectorValueType OutputVectorValueType
typename Superclass::ParametersValueType ParametersValueType
typename Superclass::InverseJacobianPositionType InverseJacobianPositionType
typename Superclass::OutputVectorType OutputVectorType
typename Superclass::OffsetType OffsetType
typename Superclass::FixedParametersType FixedParametersType
Rigid2DTransform of a vector space (e.g. space coordinates)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename Superclass::OutputCovariantVectorType OutputCovariantVectorType
typename Superclass::OutputVnlVectorType OutputVnlVectorType
void SetVarAngle(TParametersValueType angle)
typename InverseTransformBaseType::Pointer InverseTransformBasePointer
typename Superclass::JacobianPositionType JacobianPositionType
signed long OffsetValueType
Definition: itkIntTypes.h:94
typename Superclass::InputCovariantVectorType InputCovariantVectorType