VTK
vtkMatrix4x4.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMatrix4x4.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 =========================================================================*/
29 #ifndef vtkMatrix4x4_h
30 #define vtkMatrix4x4_h
31 
32 #include "vtkCommonMathModule.h" // For export macro
33 #include "vtkObject.h"
34 
35 class VTKCOMMONMATH_EXPORT vtkMatrix4x4 : public vtkObject
36 {
37 public:
39  double Element[4][4];
40 
44  static vtkMatrix4x4 *New();
45 
46  vtkTypeMacro(vtkMatrix4x4,vtkObject);
47  void PrintSelf(ostream& os, vtkIndent indent) override;
48 
54  {vtkMatrix4x4::DeepCopy(*this->Element, source); this->Modified(); }
55 
60  static void DeepCopy(double destination[16], const vtkMatrix4x4 *source)
61  {vtkMatrix4x4::DeepCopy(destination, *source->Element); }
62 
67  static void DeepCopy(double destination[16], const double source[16]);
68 
73  void DeepCopy(const double elements[16])
74  { this->DeepCopy(*this->Element, elements); this->Modified(); }
75 
79  void Zero()
80  { vtkMatrix4x4::Zero(*this->Element); this->Modified(); }
81  static void Zero(double elements[16]);
82 
86  void Identity()
87  { vtkMatrix4x4::Identity(*this->Element); this->Modified();}
88  static void Identity(double elements[16]);
89 
94  static void Invert(const vtkMatrix4x4 *in, vtkMatrix4x4 *out)
95  {vtkMatrix4x4::Invert(*in->Element, *out->Element); out->Modified(); }
96  void Invert()
97  { vtkMatrix4x4::Invert(this,this); }
98  static void Invert(const double inElements[16], double outElements[16]);
99 
103  static void Transpose(const vtkMatrix4x4 *in, vtkMatrix4x4 *out)
104  {vtkMatrix4x4::Transpose(*in->Element, *out->Element); out->Modified(); }
105  void Transpose()
106  { vtkMatrix4x4::Transpose(this,this); }
107  static void Transpose(const double inElements[16], double outElements[16]);
108 
113  void MultiplyPoint(const float in[4], float out[4])
114  {vtkMatrix4x4::MultiplyPoint(*this->Element, in, out); }
115  void MultiplyPoint(const double in[4], double out[4])
116  {vtkMatrix4x4::MultiplyPoint(*this->Element, in, out); }
117 
118  static void MultiplyPoint(const double elements[16],
119  const float in[4], float out[4]);
120  static void MultiplyPoint(const double elements[16],
121  const double in[4], double out[4]);
122 
127  float *MultiplyPoint(const float in[4]) VTK_SIZEHINT(4)
128  {return this->MultiplyFloatPoint(in); }
129  float *MultiplyFloatPoint(const float in[4]) VTK_SIZEHINT(4)
130  {this->MultiplyPoint(in,this->FloatPoint); return this->FloatPoint; }
131  double *MultiplyDoublePoint(const double in[4]) VTK_SIZEHINT(4)
132  {this->MultiplyPoint(in,this->DoublePoint); return this->DoublePoint; }
133 
135 
138  static void Multiply4x4(const vtkMatrix4x4 *a, const vtkMatrix4x4 *b,
139  vtkMatrix4x4 *c);
140  static void Multiply4x4(const double a[16], const double b[16],
141  double c[16]);
143 
147  void Adjoint(const vtkMatrix4x4 *in, vtkMatrix4x4 *out)
148  {vtkMatrix4x4::Adjoint(*in->Element, *out->Element);}
149  static void Adjoint(const double inElements[16], double outElements[16]);
150 
154  double Determinant() {return vtkMatrix4x4::Determinant(*this->Element);}
155  static double Determinant(const double elements[16]);
156 
160  void SetElement(int i, int j, double value);
161 
165  double GetElement(int i, int j) const
166  {return this->Element[i][j];}
167 
171  double *GetData() { return *this->Element; }
172 
173 protected:
174  vtkMatrix4x4() { vtkMatrix4x4::Identity(*this->Element); };
175  ~vtkMatrix4x4() override {}
176 
177  float FloatPoint[4];
178  double DoublePoint[4];
179 
180 private:
181  vtkMatrix4x4(const vtkMatrix4x4&) = delete;
182  void operator= (const vtkMatrix4x4&) = delete;
183 };
184 
185 //----------------------------------------------------------------------------
186 // Multiplies matrices a and b and stores the result in c.
187 inline void vtkMatrix4x4::Multiply4x4(const double a[16], const double b[16],
188  double c[16])
189 {
190  double tmp[16];
191 
192  for (int i = 0; i < 16; i += 4)
193  {
194  for (int j = 0; j < 4; j++)
195  {
196  tmp[i + j] = a[i + 0] * b[j + 0] +
197  a[i + 1] * b[j + 4] +
198  a[i + 2] * b[j + 8] +
199  a[i + 3] * b[j + 12];
200  }
201  }
202 
203  for (int k = 0; k < 16; k++)
204  {
205  c[k] = tmp[k];
206  }
207 }
208 
209 //----------------------------------------------------------------------------
211  const vtkMatrix4x4 *a, const vtkMatrix4x4 *b, vtkMatrix4x4 *c)
212 {
214 }
215 
216 //----------------------------------------------------------------------------
217 inline void vtkMatrix4x4::SetElement(int i, int j, double value)
218 {
219  if (this->Element[i][j] != value)
220  {
221  this->Element[i][j] = value;
222  this->Modified();
223  }
224 }
225 
226 #endif
227 
vtkMatrix4x4::SetElement
void SetElement(int i, int j, double value)
Sets the element i,j in the matrix.
Definition: vtkMatrix4x4.h:217
vtkMatrix4x4::DeepCopy
void DeepCopy(const vtkMatrix4x4 *source)
Set the elements of the matrix to the same values as the elements of the given source matrix.
Definition: vtkMatrix4x4.h:53
vtkMatrix4x4::Transpose
void Transpose()
Definition: vtkMatrix4x4.h:105
vtkX3D::value
Definition: vtkX3D.h:220
vtkMatrix4x4::Element
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:39
vtkMatrix4x4::DeepCopy
static void DeepCopy(double destination[16], const vtkMatrix4x4 *source)
Set the elements of the given destination buffer to the same values as the elements of the given sour...
Definition: vtkMatrix4x4.h:60
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkMatrix4x4::MultiplyPoint
float * MultiplyPoint(const float in[4])
For use in Java or Python.
Definition: vtkMatrix4x4.h:127
vtkMatrix4x4::GetElement
double GetElement(int i, int j) const
Returns the element i,j from the matrix.
Definition: vtkMatrix4x4.h:165
vtkMatrix4x4::MultiplyPoint
void MultiplyPoint(const double in[4], double out[4])
Definition: vtkMatrix4x4.h:115
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkMatrix4x4::Determinant
double Determinant()
Compute the determinant of the matrix and return it.
Definition: vtkMatrix4x4.h:154
vtkMatrix4x4::GetData
double * GetData()
Returns the raw double array holding the matrix.
Definition: vtkMatrix4x4.h:171
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:825
vtkMatrix4x4::vtkMatrix4x4
vtkMatrix4x4()
Definition: vtkMatrix4x4.h:174
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkMatrix4x4::Adjoint
void Adjoint(const vtkMatrix4x4 *in, vtkMatrix4x4 *out)
Compute adjoint of the matrix and put it into out.
Definition: vtkMatrix4x4.h:147
vtkMatrix4x4::MultiplyPoint
void MultiplyPoint(const float in[4], float out[4])
Multiply a homogeneous coordinate by this matrix, i.e.
Definition: vtkMatrix4x4.h:113
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkMatrix4x4::MultiplyFloatPoint
float * MultiplyFloatPoint(const float in[4])
Definition: vtkMatrix4x4.h:129
vtkObject.h
vtkMatrix4x4::~vtkMatrix4x4
~vtkMatrix4x4() override
Definition: vtkMatrix4x4.h:175
vtkMatrix4x4::Invert
void Invert()
Definition: vtkMatrix4x4.h:96
vtkMatrix4x4::Multiply4x4
static void Multiply4x4(const vtkMatrix4x4 *a, const vtkMatrix4x4 *b, vtkMatrix4x4 *c)
Multiplies matrices a and b and stores the result in c.
Definition: vtkMatrix4x4.h:210
vtkMatrix4x4::DeepCopy
void DeepCopy(const double elements[16])
Non-static member function.
Definition: vtkMatrix4x4.h:73
vtkMatrix4x4::Invert
static void Invert(const vtkMatrix4x4 *in, vtkMatrix4x4 *out)
Matrix Inversion (adapted from Richard Carling in "Graphics Gems," Academic Press,...
Definition: vtkMatrix4x4.h:94
vtkMatrix4x4::MultiplyDoublePoint
double * MultiplyDoublePoint(const double in[4])
Definition: vtkMatrix4x4.h:131
vtkMatrix4x4::Identity
void Identity()
Set equal to Identity matrix.
Definition: vtkMatrix4x4.h:86
vtkMatrix4x4::Zero
void Zero()
Set all of the elements to zero.
Definition: vtkMatrix4x4.h:79
vtkMatrix4x4::Transpose
static void Transpose(const vtkMatrix4x4 *in, vtkMatrix4x4 *out)
Transpose the matrix and put it into out.
Definition: vtkMatrix4x4.h:103