ITK  6.0.0
Insight Toolkit
itkRigid2DTransform.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 : public MatrixOffsetTransformBase<TParametersValueType, 2, 2>
57 {
58 public:
59  ITK_DISALLOW_COPY_AND_MOVE(Rigid2DTransform);
60 
66 
68  itkOverrideGetNameOfClassMacro(Rigid2DTransform);
69 
71  itkNewMacro(Self);
72 
74  static constexpr unsigned int InputSpaceDimension = 2;
75  static constexpr unsigned int OutputSpaceDimension = 2;
76  static constexpr unsigned int ParametersDimension = 3;
77 
79  using typename Superclass::ScalarType;
80 
82  using typename Superclass::ParametersType;
83  using typename Superclass::ParametersValueType;
84  using typename Superclass::FixedParametersType;
85  using typename Superclass::FixedParametersValueType;
86 
88  using typename Superclass::JacobianType;
89  using typename Superclass::JacobianPositionType;
91 
92  // / Standard matrix type for this class
93  using typename Superclass::MatrixType;
94  using typename Superclass::MatrixValueType;
95 
96  // / Standard vector type for this class
97  using typename Superclass::OffsetType;
98  using typename Superclass::OffsetValueType;
99 
100  // / Standard vector type for this class
101  using typename Superclass::InputVectorType;
102  using typename Superclass::OutputVectorType;
103  using typename Superclass::OutputVectorValueType;
104 
105  // / Standard covariant vector type for this class
108 
109  // / Standard vnl_vector type for this class
110  using typename Superclass::InputVnlVectorType;
111  using typename Superclass::OutputVnlVectorType;
112 
113  // / Standard coordinate point type for this class
114  using typename Superclass::InputPointType;
115  using typename Superclass::OutputPointType;
116 
121 
134  void
135  SetMatrix(const MatrixType & matrix) override;
136 
149  virtual void
150  SetMatrix(const MatrixType & matrix, const TParametersValueType tolerance);
151 
159  void
160  Translate(const OffsetType & offset, bool pre = false);
161 
170  inline InputPointType
171  BackTransform(const OutputPointType & point) const;
172 
173  inline InputVectorType
174  BackTransform(const OutputVectorType & vect) const;
175 
176  inline InputVnlVectorType
177  BackTransform(const OutputVnlVectorType & vect) const;
178 
180  BackTransform(const OutputCovariantVectorType & vect) const;
181 
183  void
184  SetAngle(TParametersValueType angle);
185 
186  itkGetConstReferenceMacro(Angle, TParametersValueType);
187 
189  void
190  SetAngleInDegrees(TParametersValueType angle);
191 
195  void
196  SetRotation(TParametersValueType angle)
197  {
198  this->SetAngle(angle);
199  }
200  virtual const TParametersValueType &
201  GetRotation() const
202  {
203  return m_Angle;
204  }
215  void
216  SetParameters(const ParametersType & parameters) override;
217 
226  const ParametersType &
227  GetParameters() const override;
228 
231  void
232  ComputeJacobianWithRespectToParameters(const InputPointType & p, JacobianType & j) const override;
233 
238  void
239  CloneInverseTo(Pointer & result) const;
240 
242  bool
243  GetInverse(Self * inverse) const;
244 
246  InverseTransformBasePointer
247  GetInverseTransform() const override;
248 
253  void
254  CloneTo(Pointer & result) const;
255 
257  void
258  SetIdentity() override;
259 
260 protected:
261  Rigid2DTransform(unsigned int outputSpaceDimension, unsigned int parametersDimension);
262  Rigid2DTransform(unsigned int parametersDimension);
264 
265  ~Rigid2DTransform() override = default;
266 
270  void
271  PrintSelf(std::ostream & os, Indent indent) const override;
272 
276  void
277  ComputeMatrix() override;
278 
283  void
284  ComputeMatrixParameters() override;
285 
287  void
288  SetVarAngle(TParametersValueType angle)
289  {
290  m_Angle = angle;
291  }
292 
293 private:
294  TParametersValueType m_Angle{};
295 
296 }; // class Rigid2DTransform
297 
298 // Back transform a point
299 template <typename TParametersValueType>
300 inline auto
302 {
303  itkWarningMacro("BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() "
304  "to generate an inverse transform and then perform the transform using that inverted transform.");
305  return this->GetInverseMatrix() * (point - this->GetOffset());
306 }
307 
308 // Back transform a vector
309 template <typename TParametersValueType>
310 inline auto
312 {
313  itkWarningMacro("BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() "
314  "to generate an inverse transform and then perform the transform using that inverted transform.");
315  return this->GetInverseMatrix() * vect;
316 }
317 
318 // Back transform a vnl_vector
319 template <typename TParametersValueType>
320 inline auto
322 {
323  itkWarningMacro("BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() "
324  "to generate an inverse transform and then perform the transform using that inverted transform.");
325  return this->GetInverseMatrix() * vect;
326 }
327 
328 // Back Transform a CovariantVector
329 template <typename TParametersValueType>
330 inline auto
333 {
334  itkWarningMacro("BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() "
335  "to generate an inverse transform and then perform the transform using that inverted transform.");
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 */
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::MatrixOffsetTransformBase< TParametersValueType, 2, 2 >::OutputVnlVectorType
vnl_vector_fixed< TParametersValueType, Self::OutputSpaceDimension > OutputVnlVectorType
Definition: itkMatrixOffsetTransformBase.h:171
itk::Transform::OutputVnlVectorType
vnl_vector_fixed< TParametersValueType, VOutputDimension > OutputVnlVectorType
Definition: itkTransform.h:157
itk::Vector
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
itk::MatrixOffsetTransformBase< TParametersValueType, 2, 2 >::MatrixValueType
typename MatrixType::ValueType MatrixValueType
Definition: itkMatrixOffsetTransformBase.h:181
itk::MatrixOffsetTransformBase
Matrix and Offset transformation of a vector space (e.g. space coordinates)
Definition: itkMatrixOffsetTransformBase.h:106
itk::Rigid2DTransform::SetRotation
void SetRotation(TParametersValueType angle)
Definition: itkRigid2DTransform.h:196
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::MatrixOffsetTransformBase< TParametersValueType, 2, 2 >::InverseJacobianPositionType
vnl_matrix_fixed< ParametersValueType, VInputDimension, VOutputDimension > InverseJacobianPositionType
Definition: itkTransform.h:132
itk::MatrixOffsetTransformBase< TParametersValueType, 2, 2 >::ScalarType
ParametersValueType ScalarType
Definition: itkTransform.h:127
itk::MatrixOffsetTransformBase< TParametersValueType, 2, 2 >::JacobianPositionType
vnl_matrix_fixed< ParametersValueType, VOutputDimension, VInputDimension > JacobianPositionType
Definition: itkTransform.h:131
itk::Rigid2DTransform::GetRotation
virtual const TParametersValueType & GetRotation() const
Definition: itkRigid2DTransform.h:201
itk::Rigid2DTransform
Rigid2DTransform of a vector space (e.g. space coordinates)
Definition: itkRigid2DTransform.h:56
itk::MatrixOffsetTransformBase< TParametersValueType, 2, 2 >::InverseTransformBaseType
typename Superclass::InverseTransformBaseType InverseTransformBaseType
Definition: itkMatrixOffsetTransformBase.h:197
itk::MatrixOffsetTransformBase< TParametersValueType, 2, 2 >::OutputVectorValueType
typename OutputVectorType::ValueType OutputVectorValueType
Definition: itkMatrixOffsetTransformBase.h:150
itk::point
*par Constraints *The filter requires an image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents
itk::MatrixOffsetTransformBase< TParametersValueType, 2, 2 >::InputVnlVectorType
vnl_vector_fixed< TParametersValueType, Self::InputSpaceDimension > InputVnlVectorType
Definition: itkMatrixOffsetTransformBase.h:170
itkMatrixOffsetTransformBase.h
itk::OffsetValueType
long OffsetValueType
Definition: itkIntTypes.h:97
itk::Rigid2DTransform::BackTransform
InputPointType BackTransform(const OutputPointType &point) const
Definition: itkRigid2DTransform.h:301
itk::Matrix< TParametersValueType, Self::OutputSpaceDimension, Self::InputSpaceDimension >
itk::CovariantVector
A templated class holding a n-Dimensional covariant vector.
Definition: itkCovariantVector.h:70
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::Point< TParametersValueType, Self::InputSpaceDimension >
itk::Rigid2DTransform::InverseTransformBasePointer
typename InverseTransformBaseType::Pointer InverseTransformBasePointer
Definition: itkRigid2DTransform.h:120
AddImageFilter
Definition: itkAddImageFilter.h:81
itk::Array2D
Array2D class representing a 2D array.
Definition: itkArray2D.h:42
itk::Rigid2DTransform::InverseTransformBaseType
typename Superclass::InverseTransformBaseType InverseTransformBaseType
Definition: itkRigid2DTransform.h:119
itk::Rigid2DTransform::SetVarAngle
void SetVarAngle(TParametersValueType angle)
Definition: itkRigid2DTransform.h:288
itk::Transform::InputVnlVectorType
vnl_vector_fixed< TParametersValueType, VInputDimension > InputVnlVectorType
Definition: itkTransform.h:156