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 =========================================================================*/
32 #ifndef __vtkMatrix4x4_h
33 #define __vtkMatrix4x4_h
34 
35 #include "vtkObject.h"
36 
38 {
39  // Some of the methods in here have a corresponding static (class)
40  // method taking a pointer to 16 doubles that constitutes a user
41  // supplied matrix. This allows C++ clients to allocate double arrays
42  // on the stack and manipulate them using vtkMatrix4x4 methods.
43  // This is an alternative to allowing vtkMatrix4x4 instances to be
44  // created on the stack (which is frowned upon) or doing lots of
45  // temporary heap allocation within vtkTransform and vtkActor methods,
46  // which is inefficient.
47 
48 public:
49  double Element[4][4];
50 
52  static vtkMatrix4x4 *New();
53 
54  vtkTypeMacro(vtkMatrix4x4,vtkObject);
55  void PrintSelf(ostream& os, vtkIndent indent);
56 
58 
60  void DeepCopy(const vtkMatrix4x4 *source)
61  {vtkMatrix4x4::DeepCopy(*this->Element,source); this->Modified(); }
62 //BTX
63  static void DeepCopy(double Elements[16], const vtkMatrix4x4 *source)
64  {vtkMatrix4x4::DeepCopy(Elements,*source->Element); }
65  static void DeepCopy(double Elements[16], const double newElements[16]);
66 //ETX
68 
70 
71  void DeepCopy(const double Elements[16])
72  { this->DeepCopy(*this->Element,Elements); this->Modified(); }
74 
76 
77  void Zero()
78  { vtkMatrix4x4::Zero(*this->Element); this->Modified(); }
79 //BTX
80  static void Zero(double Elements[16]);
81 //ETX
83 
85 
86  void Identity()
87  { vtkMatrix4x4::Identity(*this->Element); this->Modified();}
88 //BTX
89  static void Identity(double Elements[16]);
90 //ETX
92 
94 
96  static void Invert(const vtkMatrix4x4 *in, vtkMatrix4x4 *out)
97  {vtkMatrix4x4::Invert(*in->Element,*out->Element); out->Modified(); }
98  void Invert()
99  { vtkMatrix4x4::Invert(this,this); }
100 //BTX
101  static void Invert(const double inElements[16], double outElements[16]);
102 //ETX
104 
105 
107 
108  static void Transpose(const vtkMatrix4x4 *in, vtkMatrix4x4 *out)
109  {vtkMatrix4x4::Transpose(*in->Element,*out->Element); out->Modified(); }
110  void Transpose()
111  { vtkMatrix4x4::Transpose(this,this); }
112 //BTX
113  static void Transpose(const double inElements[16], double outElements[16]);
114 //ETX
116 
118 
120  void MultiplyPoint(const float in[4], float out[4])
121  {vtkMatrix4x4::MultiplyPoint(*this->Element,in,out); }
122  void MultiplyPoint(const double in[4], double out[4])
123  {vtkMatrix4x4::MultiplyPoint(*this->Element,in,out); }
125 
126 //BTX
127  static void MultiplyPoint(const double Elements[16],
128  const float in[4], float out[4]);
129  static void MultiplyPoint(const double Elements[16],
130  const double in[4], double out[4]);
131 //ETX
132 
134 
136  float *MultiplyPoint(const float in[4])
137  {return this->MultiplyFloatPoint(in); }
138  float *MultiplyFloatPoint(const float in[4])
139  {this->MultiplyPoint(in,this->FloatPoint); return this->FloatPoint; }
140  double *MultiplyDoublePoint(const double in[4])
141  {this->MultiplyPoint(in,this->DoublePoint); return this->DoublePoint; }
143 
145 
146  static void Multiply4x4(const vtkMatrix4x4 *a, const vtkMatrix4x4 *b, vtkMatrix4x4 *c) {
148 //BTX
149  static void Multiply4x4(const double a[16], const double b[16],
150  double c[16]);
151 //ETX
153 
155 
156  void Adjoint(const vtkMatrix4x4 *in, vtkMatrix4x4 *out)
157  {vtkMatrix4x4::Adjoint(*in->Element,*out->Element);}
158 //BTX
159  static void Adjoint(const double inElements[16], double outElements[16]);
160 //ETX
162 
164 
165  double Determinant() {return vtkMatrix4x4::Determinant(*this->Element);}
166 //BTX
167  static double Determinant(const double Elements[16]);
168 //ETX
170 
172  void SetElement(int i, int j, double value);
173 
175 
176  double GetElement(int i, int j) const
177  {return this->Element[i][j];}
179 
180 //BTX
181  double *operator[](const unsigned int i)
182  {return &(this->Element[i][0]);}
183  const double *operator[](unsigned int i) const
184  { return &(this->Element[i][0]); }
186  {this->Adjoint(&in,&out);}
188  {return this->Determinant(&in);}
190  {return vtkMatrix4x4::Determinant(*in->Element);}
192  {this->Invert(&in,&out);}
194  {this->Transpose(&in,&out);}
195  static void PointMultiply(const double Elements[16],
196  const float in[4], float out[4]);
197  static void PointMultiply(const double Elements[16],
198  const double in[4], double out[4]);
199 //ETX
200 
201 protected:
202  vtkMatrix4x4() { vtkMatrix4x4::Identity(*this->Element); };
204 
205  float FloatPoint[4];
206  double DoublePoint[4];
207 private:
208  vtkMatrix4x4(const vtkMatrix4x4&); // Not implemented
209  void operator= (const vtkMatrix4x4&); // Not implemented
210 };
211 
212 inline void vtkMatrix4x4::SetElement(int i, int j, double value)
213 {
214  if (this->Element[i][j] != value)
215  {
216  this->Element[i][j] = value;
217  this->Modified();
218  }
219 }
220 
221 #endif
222 
void Transpose(vtkMatrix4x4 &in, vtkMatrix4x4 &out)
Definition: vtkMatrix4x4.h:193
abstract base class for most VTK objects
Definition: vtkObject.h:60
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:37
void Adjoint(const vtkMatrix4x4 *in, vtkMatrix4x4 *out)
Definition: vtkMatrix4x4.h:156
float * MultiplyFloatPoint(const float in[4])
Definition: vtkMatrix4x4.h:138
double GetElement(int i, int j) const
Definition: vtkMatrix4x4.h:176
static void Multiply4x4(const vtkMatrix4x4 *a, const vtkMatrix4x4 *b, vtkMatrix4x4 *c)
Definition: vtkMatrix4x4.h:146
void SetElement(int i, int j, double value)
Definition: vtkMatrix4x4.h:212
void MultiplyPoint(const double in[4], double out[4])
Definition: vtkMatrix4x4.h:122
void Transpose()
Definition: vtkMatrix4x4.h:110
void Invert()
Definition: vtkMatrix4x4.h:98
void MultiplyPoint(const float in[4], float out[4])
Definition: vtkMatrix4x4.h:120
void DeepCopy(const vtkMatrix4x4 *source)
Definition: vtkMatrix4x4.h:60
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:37
static void Invert(const vtkMatrix4x4 *in, vtkMatrix4x4 *out)
Definition: vtkMatrix4x4.h:96
void Identity()
Definition: vtkMatrix4x4.h:86
double * MultiplyDoublePoint(const double in[4])
Definition: vtkMatrix4x4.h:140
const double * operator[](unsigned int i) const
Definition: vtkMatrix4x4.h:183
#define VTK_COMMON_EXPORT
virtual void Modified()
static void DeepCopy(double Elements[16], const vtkMatrix4x4 *source)
Definition: vtkMatrix4x4.h:63
static void Transpose(const vtkMatrix4x4 *in, vtkMatrix4x4 *out)
Definition: vtkMatrix4x4.h:108
double Determinant()
Definition: vtkMatrix4x4.h:165
double Determinant(vtkMatrix4x4 *in)
Definition: vtkMatrix4x4.h:189
double Element[4][4]
Definition: vtkMatrix4x4.h:49
void Invert(vtkMatrix4x4 &in, vtkMatrix4x4 &out)
Definition: vtkMatrix4x4.h:191
float * MultiplyPoint(const float in[4])
Definition: vtkMatrix4x4.h:136
double Determinant(vtkMatrix4x4 &in)
Definition: vtkMatrix4x4.h:187
void DeepCopy(const double Elements[16])
Definition: vtkMatrix4x4.h:71
static vtkObject * New()
void Adjoint(vtkMatrix4x4 &in, vtkMatrix4x4 &out)
Definition: vtkMatrix4x4.h:185
double * operator[](const unsigned int i)
Definition: vtkMatrix4x4.h:181