VTK  9.1.0
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=========================================================================*/
36#ifndef vtkMatrix3x3_h
37#define vtkMatrix3x3_h
38
39#include "vtkCommonMathModule.h" // For export macro
40#include "vtkObject.h"
41
42class VTKCOMMONMATH_EXPORT vtkMatrix3x3 : public vtkObject
43{
44 // Some of the methods in here have a corresponding static (class)
45 // method taking a pointer to 9 doubles that constitutes a user
46 // supplied matrix. This allows C++ clients to allocate double arrays
47 // on the stack and manipulate them using vtkMatrix3x3 methods.
48 // This is an alternative to allowing vtkMatrix3x3 instances to be
49 // created on the stack (which is frowned upon) or doing lots of
50 // temporary heap allocation within vtkTransform2D methods,
51 // which is inefficient.
52
53public:
57 static vtkMatrix3x3* New();
58
59 vtkTypeMacro(vtkMatrix3x3, vtkObject);
60 void PrintSelf(ostream& os, vtkIndent indent) override;
61
67 {
68 vtkMatrix3x3::DeepCopy(*this->Element, source);
69 this->Modified();
70 }
71 static void DeepCopy(double elements[9], vtkMatrix3x3* source)
72 {
73 vtkMatrix3x3::DeepCopy(elements, *source->Element);
74 }
75 static void DeepCopy(double elements[9], const double newElements[9]);
76
80 void DeepCopy(const double elements[9])
81 {
82 this->DeepCopy(*this->Element, elements);
83 this->Modified();
84 }
85
89 void Zero()
90 {
91 vtkMatrix3x3::Zero(*this->Element);
92 this->Modified();
93 }
94 static void Zero(double elements[9]);
95
99 void Identity()
100 {
101 vtkMatrix3x3::Identity(*this->Element);
102 this->Modified();
103 }
104 static void Identity(double elements[9]);
105
110 static void Invert(vtkMatrix3x3* in, vtkMatrix3x3* out)
111 {
113 out->Modified();
114 }
115 void Invert() { vtkMatrix3x3::Invert(this, this); }
116 static void Invert(const double inElements[9], double outElements[9]);
117
121 static void Transpose(vtkMatrix3x3* in, vtkMatrix3x3* out)
122 {
124 out->Modified();
125 }
126 void Transpose() { vtkMatrix3x3::Transpose(this, this); }
127 static void Transpose(const double inElements[9], double outElements[9]);
128
133 void MultiplyPoint(const float in[3], float out[3])
134 {
135 vtkMatrix3x3::MultiplyPoint(*this->Element, in, out);
136 }
137 void MultiplyPoint(const double in[3], double out[3])
138 {
139 vtkMatrix3x3::MultiplyPoint(*this->Element, in, out);
140 }
141
142 static void MultiplyPoint(const double elements[9], const float in[3], float out[3]);
143 static void MultiplyPoint(const double elements[9], const double in[3], double out[3]);
144
149 {
151 }
152 static void Multiply3x3(const double a[9], const double b[9], double c[9]);
153
158 {
160 }
161 static void Adjoint(const double inElements[9], double outElements[9]);
162
166 double Determinant() { return vtkMatrix3x3::Determinant(*this->Element); }
167 static double Determinant(const double elements[9]);
168
172 void SetElement(int i, int j, double value);
173
177 double GetElement(int i, int j) const { return this->Element[i][j]; }
178
179 // Descption:
180 // Returns true if this matrix is equal to the identity matrix.
181 bool IsIdentity();
182
186 double* GetData() VTK_SIZEHINT(9) { return *this->Element; }
187
191 const double* GetData() const { return *this->Element; }
192
193protected:
195 ~vtkMatrix3x3() override;
196
197 double Element[3][3]; // The elements of the 3x3 matrix
198
199private:
200 vtkMatrix3x3(const vtkMatrix3x3&) = delete;
201 void operator=(const vtkMatrix3x3&) = delete;
202};
203
204inline void vtkMatrix3x3::SetElement(int i, int j, double value)
205{
206 if (this->Element[i][j] != value)
207 {
208 this->Element[i][j] = value;
209 this->Modified();
210 }
211}
212
214{
215 double* M = *this->Element;
216 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 &&
217 M[5] == 0.0 && M[6] == 0.0 && M[7] == 0.0)
218 {
219 return true;
220 }
221 else
222 {
223 return false;
224 }
225}
226
227#endif
a simple class to control print indentation
Definition: vtkIndent.h:43
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:43
static void Identity(double elements[9])
const double * GetData() const
Return a pointer to the first element of the matrix (double[9]).
Definition: vtkMatrix3x3.h:191
double Determinant()
Compute the determinant of the matrix and return it.
Definition: vtkMatrix3x3.h:166
static void Multiply3x3(vtkMatrix3x3 *a, vtkMatrix3x3 *b, vtkMatrix3x3 *c)
Multiplies matrices a and b and stores the result in c (c=a*b).
Definition: vtkMatrix3x3.h:148
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.
Definition: vtkMatrix3x3.h:80
static void Zero(double elements[9])
void MultiplyPoint(const float in[3], float out[3])
Multiply a homogeneous coordinate by this matrix, i.e.
Definition: vtkMatrix3x3.h:133
bool IsIdentity()
Definition: vtkMatrix3x3.h:213
static double Determinant(const double elements[9])
double GetElement(int i, int j) const
Returns the element i,j from the matrix.
Definition: vtkMatrix3x3.h:177
double Element[3][3]
Definition: vtkMatrix3x3.h:197
void Zero()
Set all of the elements to zero.
Definition: vtkMatrix3x3.h:89
void MultiplyPoint(const double in[3], double out[3])
Definition: vtkMatrix3x3.h:137
void SetElement(int i, int j, double value)
Sets the element i,j in the matrix.
Definition: vtkMatrix3x3.h:204
static void DeepCopy(double elements[9], const double newElements[9])
static void DeepCopy(double elements[9], vtkMatrix3x3 *source)
Definition: vtkMatrix3x3.h:71
static void Invert(vtkMatrix3x3 *in, vtkMatrix3x3 *out)
Matrix Inversion (adapted from Richard Carling in "Graphics Gems," Academic Press,...
Definition: vtkMatrix3x3.h:110
static void Multiply3x3(const double a[9], const double b[9], double c[9])
void Transpose()
Definition: vtkMatrix3x3.h:126
static void MultiplyPoint(const double elements[9], const double in[3], double out[3])
void Identity()
Set equal to Identity matrix.
Definition: vtkMatrix3x3.h:99
static void Transpose(vtkMatrix3x3 *in, vtkMatrix3x3 *out)
Transpose the matrix and put it into out.
Definition: vtkMatrix3x3.h:121
void DeepCopy(vtkMatrix3x3 *source)
Set the elements of the matrix to the same values as the elements of the source Matrix.
Definition: vtkMatrix3x3.h:66
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]).
Definition: vtkMatrix3x3.h:186
void Adjoint(vtkMatrix3x3 *in, vtkMatrix3x3 *out)
Compute adjoint of the matrix and put it into out.
Definition: vtkMatrix3x3.h:157
static void Adjoint(const double inElements[9], double outElements[9])
abstract base class for most VTK objects
Definition: vtkObject.h:63
virtual void Modified()
Update the modification time for this object.
@ value
Definition: vtkX3D.h:226
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_SIZEHINT(...)