VTK  9.7.1
vtkTransform2D.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
29 #ifndef vtkTransform2D_h
30 #define vtkTransform2D_h
31 
32 #include "vtkCommonTransformsModule.h" // For export macro
33 #include "vtkObject.h"
34 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
35 
36 #include "vtkMatrix3x3.h" // Needed for inline methods
37 
38 VTK_ABI_NAMESPACE_BEGIN
39 class vtkPoints2D;
40 
41 class VTKCOMMONTRANSFORMS_EXPORT VTK_MARSHALAUTO vtkTransform2D : public vtkObject
42 {
43 public:
44  static vtkTransform2D* New();
45  vtkTypeMacro(vtkTransform2D, vtkObject);
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
51  void Identity();
52 
56  void Inverse();
57 
62  void Translate(double x, double y);
63  void Translate(const double x[2]) { this->Translate(x[0], x[1]); }
64  void Translate(const float x[2]) { this->Translate(x[0], x[1]); }
65 
70  void Rotate(double angle);
71 
76  void Scale(double x, double y);
77  void Scale(const double s[2]) { this->Scale(s[0], s[1]); }
78  void Scale(const float s[2]) { this->Scale(s[0], s[1]); }
79 
83  void SetMatrix(vtkMatrix3x3* matrix) { this->SetMatrix(matrix->GetData()); }
84  void SetMatrix(const double elements[9]);
85 
87 
90  vtkGetObjectMacro(Matrix, vtkMatrix3x3);
91  void GetMatrix(vtkMatrix3x3* matrix);
93 
95 
100  void GetPosition(double pos[2]);
101  void GetPosition(float pos[2])
102  {
103  double temp[2];
104  this->GetPosition(temp);
105  pos[0] = static_cast<float>(temp[0]);
106  pos[1] = static_cast<float>(temp[1]);
107  }
109 
111 
116  void GetScale(double scale[2]);
117  void GetScale(float pos[2])
118  {
119  double temp[2];
120  this->GetScale(temp);
121  pos[0] = static_cast<float>(temp[0]);
122  pos[1] = static_cast<float>(temp[1]);
123  }
125 
130  void GetInverse(vtkMatrix3x3* inverse);
131 
137  void GetTranspose(vtkMatrix3x3* transpose);
138 
142  vtkMTimeType GetMTime() override;
143 
149  void TransformPoints(const float* inPts, float* outPts, int n);
150 
156  void TransformPoints(const double* inPts, double* outPts, int n);
157 
162  void TransformPoints(vtkPoints2D* inPts, vtkPoints2D* outPts);
163 
169  void InverseTransformPoints(const float* inPts, float* outPts, int n);
170 
176  void InverseTransformPoints(const double* inPts, double* outPts, int n);
177 
182  void InverseTransformPoints(vtkPoints2D* inPts, vtkPoints2D* outPts);
183 
185 
190  void MultiplyPoint(const float in[3], float out[3]) { this->GetMatrix()->MultiplyPoint(in, out); }
191  void MultiplyPoint(const double in[3], double out[3])
192  {
193  this->GetMatrix()->MultiplyPoint(in, out);
194  }
196 
197 protected:
198  vtkTransform2D();
199  ~vtkTransform2D() override;
200 
201  void InternalDeepCopy(vtkTransform2D* t);
202 
205 
206 private:
207  vtkTransform2D(const vtkTransform2D&) = delete;
208  void operator=(const vtkTransform2D&) = delete;
209 };
210 
211 VTK_ABI_NAMESPACE_END
212 #endif
vtkMatrix3x3 * InverseMatrix
abstract base class for most VTK objects
Definition: vtkObject.h:52
void GetScale(float pos[2])
Return the x and y scale from the current transformation matrix as an array of two floating point num...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
void Translate(const double x[2])
a simple class to control print indentation
Definition: vtkIndent.h:28
represent and manipulate 2D points
Definition: vtkPoints2D.h:27
virtual vtkMTimeType GetMTime()
Return this object's modified time.
describes linear transformations via a 3x3 matrix
double * GetData()
Return a pointer to the first element of the matrix (double[9]).
Definition: vtkMatrix3x3.h:170
void MultiplyPoint(const double in[3], double out[3])
Use this method only if you wish to compute the transformation in homogeneous (x,y,w) coordinates, otherwise use TransformPoint().
vtkMatrix3x3 * Matrix
void GetPosition(float pos[2])
Return the position from the current transformation matrix as an array of two floating point numbers...
void Translate(const float x[2])
void SetMatrix(vtkMatrix3x3 *matrix)
Set the current matrix directly.
#define VTK_MARSHALAUTO
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:26
void Scale(const double s[2])
void MultiplyPoint(const float in[3], float out[3])
Use this method only if you wish to compute the transformation in homogeneous (x,y,w) coordinates, otherwise use TransformPoint().
void Scale(const float s[2])