VTK  9.3.0
vtkMatrix3x3.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
18 #ifndef vtkMatrix3x3_h
19 #define vtkMatrix3x3_h
20 
21 #include "vtkCommonMathModule.h" // For export macro
22 #include "vtkObject.h"
23 
24 VTK_ABI_NAMESPACE_BEGIN
25 class VTKCOMMONMATH_EXPORT vtkMatrix3x3 : public vtkObject
26 {
27  // Some of the methods in here have a corresponding static (class)
28  // method taking a pointer to 9 doubles that constitutes a user
29  // supplied matrix. This allows C++ clients to allocate double arrays
30  // on the stack and manipulate them using vtkMatrix3x3 methods.
31  // This is an alternative to allowing vtkMatrix3x3 instances to be
32  // created on the stack (which is frowned upon) or doing lots of
33  // temporary heap allocation within vtkTransform2D methods,
34  // which is inefficient.
35 
36 public:
40  static vtkMatrix3x3* New();
41 
42  vtkTypeMacro(vtkMatrix3x3, vtkObject);
43  void PrintSelf(ostream& os, vtkIndent indent) override;
44 
50  {
51  vtkMatrix3x3::DeepCopy(*this->Element, source);
52  this->Modified();
53  }
54  static void DeepCopy(double elements[9], vtkMatrix3x3* source)
55  {
56  vtkMatrix3x3::DeepCopy(elements, *source->Element);
57  }
58  static void DeepCopy(double elements[9], const double newElements[9]);
59 
63  void DeepCopy(const double elements[9])
64  {
65  vtkMatrix3x3::DeepCopy(*this->Element, elements);
66  this->Modified();
67  }
68 
72  void Zero()
73  {
74  vtkMatrix3x3::Zero(*this->Element);
75  this->Modified();
76  }
77  static void Zero(double elements[9]);
78 
82  void Identity()
83  {
84  vtkMatrix3x3::Identity(*this->Element);
85  this->Modified();
86  }
87  static void Identity(double elements[9]);
88 
93  static void Invert(vtkMatrix3x3* in, vtkMatrix3x3* out)
94  {
96  out->Modified();
97  }
98  void Invert() { vtkMatrix3x3::Invert(this, this); }
99  static void Invert(const double inElements[9], double outElements[9]);
100 
104  static void Transpose(vtkMatrix3x3* in, vtkMatrix3x3* out)
105  {
107  out->Modified();
108  }
109  void Transpose() { vtkMatrix3x3::Transpose(this, this); }
110  static void Transpose(const double inElements[9], double outElements[9]);
111 
116  void MultiplyPoint(const float in[3], float out[3])
117  {
118  vtkMatrix3x3::MultiplyPoint(*this->Element, in, out);
119  }
120  void MultiplyPoint(const double in[3], double out[3])
121  {
122  vtkMatrix3x3::MultiplyPoint(*this->Element, in, out);
123  }
124 
125  static void MultiplyPoint(const double elements[9], const float in[3], float out[3]);
126  static void MultiplyPoint(const double elements[9], const double in[3], double out[3]);
127 
132  {
134  }
135  static void Multiply3x3(const double a[9], const double b[9], double c[9]);
136 
141  {
143  }
144  static void Adjoint(const double inElements[9], double outElements[9]);
145 
149  double Determinant() { return vtkMatrix3x3::Determinant(*this->Element); }
150  static double Determinant(const double elements[9]);
151 
155  void SetElement(int i, int j, double value);
156 
160  double GetElement(int i, int j) const { return this->Element[i][j]; }
161 
162  // Descption:
163  // Returns true if this matrix is equal to the identity matrix.
164  bool IsIdentity();
165 
169  double* GetData() VTK_SIZEHINT(9) { return *this->Element; }
170 
174  const double* GetData() const { return *this->Element; }
175 
176 protected:
178  ~vtkMatrix3x3() override;
179 
180  double Element[3][3]; // The elements of the 3x3 matrix
181 
182 private:
183  vtkMatrix3x3(const vtkMatrix3x3&) = delete;
184  void operator=(const vtkMatrix3x3&) = delete;
185 };
186 
187 inline void vtkMatrix3x3::SetElement(int i, int j, double value)
188 {
189  if (this->Element[i][j] != value)
190  {
191  this->Element[i][j] = value;
192  this->Modified();
193  }
194 }
195 
197 {
198  double* M = *this->Element;
199  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 &&
200  M[5] == 0.0 && M[6] == 0.0 && M[7] == 0.0)
201  {
202  return true;
203  }
204  else
205  {
206  return false;
207  }
208 }
209 
210 VTK_ABI_NAMESPACE_END
211 #endif
a simple class to control print indentation
Definition: vtkIndent.h:29
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:26
static void Identity(double elements[9])
double Determinant()
Compute the determinant of the matrix and return it.
Definition: vtkMatrix3x3.h:149
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:131
static void Invert(const double inElements[9], double outElements[9])
const double * GetData() const
Return a pointer to the first element of the matrix (double[9]).
Definition: vtkMatrix3x3.h:174
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])
static vtkMatrix3x3 * New()
Construct a 3x3 identity matrix.
~vtkMatrix3x3() override
double * GetData()
Return a pointer to the first element of the matrix (double[9]).
Definition: vtkMatrix3x3.h:169
void DeepCopy(const double elements[9])
Non-static member function.
Definition: vtkMatrix3x3.h:63
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:116
bool IsIdentity()
Definition: vtkMatrix3x3.h:196
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:160
double Element[3][3]
Definition: vtkMatrix3x3.h:180
void Zero()
Set all of the elements to zero.
Definition: vtkMatrix3x3.h:72
void MultiplyPoint(const double in[3], double out[3])
Definition: vtkMatrix3x3.h:120
void SetElement(int i, int j, double value)
Sets the element i,j in the matrix.
Definition: vtkMatrix3x3.h:187
static void DeepCopy(double elements[9], const double newElements[9])
static void DeepCopy(double elements[9], vtkMatrix3x3 *source)
Definition: vtkMatrix3x3.h:54
static void Invert(vtkMatrix3x3 *in, vtkMatrix3x3 *out)
Matrix Inversion (adapted from Richard Carling in "Graphics Gems," Academic Press,...
Definition: vtkMatrix3x3.h:93
static void Multiply3x3(const double a[9], const double b[9], double c[9])
void Transpose()
Definition: vtkMatrix3x3.h:109
static void MultiplyPoint(const double elements[9], const double in[3], double out[3])
void Identity()
Set equal to Identity matrix.
Definition: vtkMatrix3x3.h:82
void Invert()
Definition: vtkMatrix3x3.h:98
static void Transpose(vtkMatrix3x3 *in, vtkMatrix3x3 *out)
Transpose the matrix and put it into out.
Definition: vtkMatrix3x3.h:104
void DeepCopy(vtkMatrix3x3 *source)
Set the elements of the matrix to the same values as the elements of the source Matrix.
Definition: vtkMatrix3x3.h:49
static void MultiplyPoint(const double elements[9], const float in[3], float out[3])
void Adjoint(vtkMatrix3x3 *in, vtkMatrix3x3 *out)
Compute adjoint of the matrix and put it into out.
Definition: vtkMatrix3x3.h:140
static void Adjoint(const double inElements[9], double outElements[9])
abstract base class for most VTK objects
Definition: vtkObject.h:52
virtual void Modified()
Update the modification time for this object.
@ value
Definition: vtkX3D.h:220
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_SIZEHINT(...)