VTK  9.2.6
vtkMatrix3x3.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkMatrix3x3.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=========================================================================*/
39#ifndef vtkMatrix3x3_h
40#define vtkMatrix3x3_h
41
42#include "vtkCommonMathModule.h" // For export macro
43#include "vtkObject.h"
44
45class VTKCOMMONMATH_EXPORT vtkMatrix3x3 : public vtkObject
46{
47 // Some of the methods in here have a corresponding static (class)
48 // method taking a pointer to 9 doubles that constitutes a user
49 // supplied matrix. This allows C++ clients to allocate double arrays
50 // on the stack and manipulate them using vtkMatrix3x3 methods.
51 // This is an alternative to allowing vtkMatrix3x3 instances to be
52 // created on the stack (which is frowned upon) or doing lots of
53 // temporary heap allocation within vtkTransform2D methods,
54 // which is inefficient.
55
56public:
60 static vtkMatrix3x3* New();
61
62 vtkTypeMacro(vtkMatrix3x3, vtkObject);
63 void PrintSelf(ostream& os, vtkIndent indent) override;
64
70 {
71 vtkMatrix3x3::DeepCopy(*this->Element, source);
72 this->Modified();
73 }
74 static void DeepCopy(double elements[9], vtkMatrix3x3* source)
75 {
76 vtkMatrix3x3::DeepCopy(elements, *source->Element);
77 }
78 static void DeepCopy(double elements[9], const double newElements[9]);
79
83 void DeepCopy(const double elements[9])
84 {
85 this->DeepCopy(*this->Element, elements);
86 this->Modified();
87 }
88
92 void Zero()
93 {
94 vtkMatrix3x3::Zero(*this->Element);
95 this->Modified();
96 }
97 static void Zero(double elements[9]);
98
102 void Identity()
103 {
104 vtkMatrix3x3::Identity(*this->Element);
105 this->Modified();
106 }
107 static void Identity(double elements[9]);
108
113 static void Invert(vtkMatrix3x3* in, vtkMatrix3x3* out)
114 {
116 out->Modified();
117 }
118 void Invert() { vtkMatrix3x3::Invert(this, this); }
119 static void Invert(const double inElements[9], double outElements[9]);
120
124 static void Transpose(vtkMatrix3x3* in, vtkMatrix3x3* out)
125 {
127 out->Modified();
128 }
129 void Transpose() { vtkMatrix3x3::Transpose(this, this); }
130 static void Transpose(const double inElements[9], double outElements[9]);
131
136 void MultiplyPoint(const float in[3], float out[3])
137 {
138 vtkMatrix3x3::MultiplyPoint(*this->Element, in, out);
139 }
140 void MultiplyPoint(const double in[3], double out[3])
141 {
142 vtkMatrix3x3::MultiplyPoint(*this->Element, in, out);
143 }
144
145 static void MultiplyPoint(const double elements[9], const float in[3], float out[3]);
146 static void MultiplyPoint(const double elements[9], const double in[3], double out[3]);
147
152 {
154 }
155 static void Multiply3x3(const double a[9], const double b[9], double c[9]);
156
161 {
163 }
164 static void Adjoint(const double inElements[9], double outElements[9]);
165
169 double Determinant() { return vtkMatrix3x3::Determinant(*this->Element); }
170 static double Determinant(const double elements[9]);
171
175 void SetElement(int i, int j, double value);
176
180 double GetElement(int i, int j) const { return this->Element[i][j]; }
181
182 // Descption:
183 // Returns true if this matrix is equal to the identity matrix.
184 bool IsIdentity();
185
189 double* GetData() VTK_SIZEHINT(9) { return *this->Element; }
190
194 const double* GetData() const { return *this->Element; }
195
196protected:
198 ~vtkMatrix3x3() override;
199
200 double Element[3][3]; // The elements of the 3x3 matrix
201
202private:
203 vtkMatrix3x3(const vtkMatrix3x3&) = delete;
204 void operator=(const vtkMatrix3x3&) = delete;
205};
206
207inline void vtkMatrix3x3::SetElement(int i, int j, double value)
208{
209 if (this->Element[i][j] != value)
210 {
211 this->Element[i][j] = value;
212 this->Modified();
213 }
214}
215
217{
218 double* M = *this->Element;
219 if (M[0] == 1.0 && M[4] == 1.0 && M[8] == 1.0 && M[1] == 0.0 && M[2] == 0.0 && M[3] == 0.0 &&
220 M[5] == 0.0 && M[6] == 0.0 && M[7] == 0.0)
221 {
222 return true;
223 }
224 else
225 {
226 return false;
227 }
228}
229
230#endif
a simple class to control print indentation
Definition vtkIndent.h:49
represent and manipulate 3x3 transformation matrices
static void Identity(double elements[9])
const double * GetData() const
Return a pointer to the first element of the matrix (double[9]).
double Determinant()
Compute the determinant of the matrix and return it.
static void Multiply3x3(vtkMatrix3x3 *a, vtkMatrix3x3 *b, vtkMatrix3x3 *c)
Multiplies matrices a and b and stores the result in c (c=a*b).
static void Invert(const double inElements[9], double outElements[9])
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static void Transpose(const double inElements[9], double outElements[9])
~vtkMatrix3x3() override
void DeepCopy(const double elements[9])
Non-static member function.
static void Zero(double elements[9])
void MultiplyPoint(const float in[3], float out[3])
Multiply a homogeneous coordinate by this matrix, i.e.
bool IsIdentity()
static double Determinant(const double elements[9])
double GetElement(int i, int j) const
Returns the element i,j from the matrix.
double Element[3][3]
void Zero()
Set all of the elements to zero.
void MultiplyPoint(const double in[3], double out[3])
void SetElement(int i, int j, double value)
Sets the element i,j in the matrix.
static void DeepCopy(double elements[9], const double newElements[9])
static void DeepCopy(double elements[9], vtkMatrix3x3 *source)
static void Invert(vtkMatrix3x3 *in, vtkMatrix3x3 *out)
Matrix Inversion (adapted from Richard Carling in "Graphics Gems," Academic Press,...
static void Multiply3x3(const double a[9], const double b[9], double c[9])
static void MultiplyPoint(const double elements[9], const double in[3], double out[3])
void Identity()
Set equal to Identity matrix.
static void Transpose(vtkMatrix3x3 *in, vtkMatrix3x3 *out)
Transpose the matrix and put it into out.
void DeepCopy(vtkMatrix3x3 *source)
Set the elements of the matrix to the same values as the elements of the source Matrix.
static void MultiplyPoint(const double elements[9], const float in[3], float out[3])
static vtkMatrix3x3 * New()
Construct a 3x3 identity matrix.
double * GetData()
Return a pointer to the first element of the matrix (double[9]).
void Adjoint(vtkMatrix3x3 *in, vtkMatrix3x3 *out)
Compute adjoint of the matrix and put it into out.
static void Adjoint(const double inElements[9], double outElements[9])
abstract base class for most VTK objects
Definition vtkObject.h:72
virtual void Modified()
Update the modification time for this object.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_SIZEHINT(...)