VTK
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 
41 #ifndef vtkTransform2D_h
42 #define vtkTransform2D_h
43 
44 #include "vtkCommonTransformsModule.h" // For export macro
45 #include "vtkObject.h"
46 
47 #include "vtkMatrix3x3.h" // Needed for inline methods
48 
49 class vtkPoints2D;
50 
51 class VTKCOMMONTRANSFORMS_EXPORT vtkTransform2D : public vtkObject
52 {
53  public:
54  static vtkTransform2D *New();
55  vtkTypeMacro(vtkTransform2D,vtkObject);
56  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
57 
61  void Identity();
62 
66  void Inverse();
67 
72  void Translate(double x, double y);
73  void Translate(const double x[2]) { this->Translate(x[0], x[1]); }
74  void Translate(const float x[2]) { this->Translate(x[0], x[1]); }
75 
80  void Rotate(double angle);
81 
86  void Scale(double x, double y);
87  void Scale(const double s[2]) { this->Scale(s[0], s[1]); }
88  void Scale(const float s[2]) { this->Scale(s[0], s[1]); }
89 
93  void SetMatrix(vtkMatrix3x3 *matrix) {
94  this->SetMatrix(matrix->GetData()); }
95  void SetMatrix(const double elements[9]);
96 
98 
101  vtkGetObjectMacro(Matrix, vtkMatrix3x3);
102  void GetMatrix(vtkMatrix3x3 *matrix);
104 
106 
111  void GetPosition(double pos[2]);
112  void GetPosition(float pos[2]) {
113  double temp[2];
114  this->GetPosition(temp);
115  pos[0] = static_cast<float>(temp[0]);
116  pos[1] = static_cast<float>(temp[1]); }
118 
120 
125  void GetScale(double pos[2]);
126  void GetScale(float pos[2]) {
127  double temp[2];
128  this->GetScale(temp);
129  pos[0] = static_cast<float>(temp[0]);
130  pos[1] = static_cast<float>(temp[1]); }
132 
137  void GetInverse(vtkMatrix3x3 *inverse);
138 
144  void GetTranspose(vtkMatrix3x3 *transpose);
145 
149  vtkMTimeType GetMTime() VTK_OVERRIDE;
150 
156  void TransformPoints(const float *inPts, float *outPts, int n);
157 
163  void TransformPoints(const double *inPts, double *outPts, int n);
164 
169  void TransformPoints(vtkPoints2D *inPts, vtkPoints2D *outPts);
170 
176  void InverseTransformPoints(const float *inPts, float *outPts, int n);
177 
183  void InverseTransformPoints(const double *inPts, double *outPts, int n);
184 
189  void InverseTransformPoints(vtkPoints2D *inPts, vtkPoints2D *outPts);
190 
192 
197  void MultiplyPoint(const float in[3], float out[3]) {
198  this->GetMatrix()->MultiplyPoint(in,out);};
199  void MultiplyPoint(const double in[3], double out[3]) {
200  this->GetMatrix()->MultiplyPoint(in,out);};
202 
203 protected:
204  vtkTransform2D ();
205  ~vtkTransform2D () VTK_OVERRIDE;
206 
207  void InternalDeepCopy(vtkTransform2D *t);
208 
209  vtkMatrix3x3 *Matrix;
210  vtkMatrix3x3 *InverseMatrix;
211 
212 private:
213  vtkTransform2D (const vtkTransform2D&) VTK_DELETE_FUNCTION;
214  void operator=(const vtkTransform2D&) VTK_DELETE_FUNCTION;
215 };
216 
217 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:59
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.
void Translate(const double x[2])
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
a simple class to control print indentation
Definition: vtkIndent.h:39
represent and manipulate 2D points
Definition: vtkPoints2D.h:36
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:177
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().
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.
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:36
void Scale(const double s[2])
void Scale(const float s[2])