VTK  9.1.20211115
vtkTransform2D.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkTransform2D.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
35 #ifndef vtkTransform2D_h
36 #define vtkTransform2D_h
37 
38 #include "vtkCommonTransformsModule.h" // For export macro
39 #include "vtkObject.h"
40 
41 #include "vtkMatrix3x3.h" // Needed for inline methods
42 
43 class vtkPoints2D;
44 
45 class VTKCOMMONTRANSFORMS_EXPORT vtkTransform2D : public vtkObject
46 {
47 public:
48  static vtkTransform2D* New();
49  vtkTypeMacro(vtkTransform2D, vtkObject);
50  void PrintSelf(ostream& os, vtkIndent indent) override;
51 
55  void Identity();
56 
60  void Inverse();
61 
66  void Translate(double x, double y);
67  void Translate(const double x[2]) { this->Translate(x[0], x[1]); }
68  void Translate(const float x[2]) { this->Translate(x[0], x[1]); }
69 
74  void Rotate(double angle);
75 
80  void Scale(double x, double y);
81  void Scale(const double s[2]) { this->Scale(s[0], s[1]); }
82  void Scale(const float s[2]) { this->Scale(s[0], s[1]); }
83 
87  void SetMatrix(vtkMatrix3x3* matrix) { this->SetMatrix(matrix->GetData()); }
88  void SetMatrix(const double elements[9]);
89 
91 
94  vtkGetObjectMacro(Matrix, vtkMatrix3x3);
95  void GetMatrix(vtkMatrix3x3* matrix);
97 
99 
104  void GetPosition(double pos[2]);
105  void GetPosition(float pos[2])
106  {
107  double temp[2];
108  this->GetPosition(temp);
109  pos[0] = static_cast<float>(temp[0]);
110  pos[1] = static_cast<float>(temp[1]);
111  }
113 
115 
120  void GetScale(double scale[2]);
121  void GetScale(float pos[2])
122  {
123  double temp[2];
124  this->GetScale(temp);
125  pos[0] = static_cast<float>(temp[0]);
126  pos[1] = static_cast<float>(temp[1]);
127  }
129 
134  void GetInverse(vtkMatrix3x3* inverse);
135 
141  void GetTranspose(vtkMatrix3x3* transpose);
142 
146  vtkMTimeType GetMTime() override;
147 
153  void TransformPoints(const float* inPts, float* outPts, int n);
154 
160  void TransformPoints(const double* inPts, double* outPts, int n);
161 
166  void TransformPoints(vtkPoints2D* inPts, vtkPoints2D* outPts);
167 
173  void InverseTransformPoints(const float* inPts, float* outPts, int n);
174 
180  void InverseTransformPoints(const double* inPts, double* outPts, int n);
181 
187 
189 
194  void MultiplyPoint(const float in[3], float out[3]) { this->GetMatrix()->MultiplyPoint(in, out); }
195  void MultiplyPoint(const double in[3], double out[3])
196  {
197  this->GetMatrix()->MultiplyPoint(in, out);
198  }
200 
201 protected:
203  ~vtkTransform2D() override;
204 
206 
209 
210 private:
211  vtkTransform2D(const vtkTransform2D&) = delete;
212  void operator=(const vtkTransform2D&) = delete;
213 };
214 
215 #endif
a simple class to control print indentation
Definition: vtkIndent.h:113
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:63
double * GetData()
Return a pointer to the first element of the matrix (double[9]).
Definition: vtkMatrix3x3.h:206
abstract base class for most VTK objects
Definition: vtkObject.h:82
represent and manipulate 2D points
Definition: vtkPoints2D.h:34
describes linear transformations via a 3x3 matrix
vtkMTimeType GetMTime() override
Override GetMTime to account for input and concatenation.
void SetMatrix(vtkMatrix3x3 *matrix)
Set the current matrix directly.
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 Translate(const float x[2])
void MultiplyPoint(const double in[3], double out[3])
Use this method only if you wish to compute the transformation in homogeneous (x,y,...
void GetTranspose(vtkMatrix3x3 *transpose)
Return a matrix which is the transpose of the current transformation matrix.
void GetPosition(float pos[2])
Return the position from the current transformation matrix as an array of two floating point numbers.
void Rotate(double angle)
Create a rotation matrix and concatenate it with the current transformation.
vtkMatrix3x3 * InverseMatrix
void Scale(const float s[2])
void TransformPoints(const float *inPts, float *outPts, int n)
Apply the transformation to a series of points, and append the results to outPts.
void SetMatrix(const double elements[9])
vtkMatrix3x3 * Matrix
void GetInverse(vtkMatrix3x3 *inverse)
Return a matrix which is the inverse of the current transformation matrix.
void InverseTransformPoints(const float *inPts, float *outPts, int n)
Apply the transformation to a series of points, and append the results to outPts.
~vtkTransform2D() override
void MultiplyPoint(const float in[3], float out[3])
Use this method only if you wish to compute the transformation in homogeneous (x,y,...
void Scale(double x, double y)
Create a scale matrix (i.e.
void Inverse()
Invert the transformation.
void InternalDeepCopy(vtkTransform2D *t)
static vtkTransform2D * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Identity()
Set the transformation to the identity transformation.
void GetScale(double scale[2])
Return the x and y scale from the current transformation matrix as an array of two floating point num...
void Scale(const double s[2])
void GetMatrix(vtkMatrix3x3 *matrix)
Get the underlying 3x3 matrix.
void InverseTransformPoints(vtkPoints2D *inPts, vtkPoints2D *outPts)
Apply the transformation to a series of points, and append the results to outPts.
void InverseTransformPoints(const double *inPts, double *outPts, int n)
Apply the transformation to a series of points, and append the results to outPts.
void TransformPoints(const double *inPts, double *outPts, int n)
Apply the transformation to a series of points, and append the results to outPts.
void Translate(const double x[2])
void GetPosition(double pos[2])
Return the position from the current transformation matrix as an array of two floating point numbers.
void Translate(double x, double y)
Create a translation matrix and concatenate it with the current transformation.
void TransformPoints(vtkPoints2D *inPts, vtkPoints2D *outPts)
Apply the transformation to a series of points, and append the results to outPts.
@ scale
Definition: vtkX3D.h:235
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287