Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

dox/Common/vtkMatrix4x4.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkMatrix4x4.h,v $ 00005 Language: C++ 00006 00007 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 00008 All rights reserved. 00009 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notice for more information. 00014 00015 =========================================================================*/ 00033 #ifndef __vtkMatrix4x4_h 00034 #define __vtkMatrix4x4_h 00035 00036 #include "vtkObject.h" 00037 00038 class VTK_COMMON_EXPORT vtkMatrix4x4 : public vtkObject 00039 { 00040 // Some of the methods in here have a corresponding static (class) 00041 // method taking a pointer to 16 doubles that constitutes a user 00042 // supplied matrix. This allows C++ clients to allocate double arrays 00043 // on the stack and manipulate them using vtkMatrix4x4 methods. 00044 // This is an alternative to allowing vtkMatrix4x4 instances to be 00045 // created on the stack (which is frowned upon) or doing lots of 00046 // temporary heap allocation within vtkTransform and vtkActor methods, 00047 // which is inefficient. 00048 00049 public: 00050 double Element[4][4]; 00051 00053 static vtkMatrix4x4 *New(); 00054 00055 vtkTypeRevisionMacro(vtkMatrix4x4,vtkObject); 00056 void PrintSelf(ostream& os, vtkIndent indent); 00057 00059 00061 void DeepCopy(vtkMatrix4x4 *source) 00062 {vtkMatrix4x4::DeepCopy(*this->Element,source); this->Modified(); } 00064 //BTX 00065 static void DeepCopy(double Elements[16], vtkMatrix4x4 *source) 00066 {vtkMatrix4x4::DeepCopy(Elements,*source->Element); } 00067 static void DeepCopy(double Elements[16], const double newElements[16]); 00068 //ETX 00069 00071 00072 void DeepCopy(const double Elements[16]) 00073 { this->DeepCopy(*this->Element,Elements); this->Modified(); } 00075 00077 00078 void Zero() 00079 { vtkMatrix4x4::Zero(*this->Element); this->Modified(); } 00081 //BTX 00082 static void Zero(double Elements[16]); 00083 //ETX 00084 00086 00087 void Identity() 00088 { vtkMatrix4x4::Identity(*this->Element); this->Modified();} 00090 //BTX 00091 static void Identity(double Elements[16]); 00092 //ETX 00093 00095 00097 static void Invert(vtkMatrix4x4 *in, vtkMatrix4x4 *out) 00098 {vtkMatrix4x4::Invert(*in->Element,*out->Element); out->Modified(); } 00099 void Invert() 00100 { vtkMatrix4x4::Invert(this,this); } 00102 //BTX 00103 static void Invert(const double inElements[16], double outElements[16]); 00104 //ETX 00105 00106 00108 00109 static void Transpose(vtkMatrix4x4 *in, vtkMatrix4x4 *out) 00110 {vtkMatrix4x4::Transpose(*in->Element,*out->Element); out->Modified(); } 00111 void Transpose() 00112 { vtkMatrix4x4::Transpose(this,this); } 00114 //BTX 00115 static void Transpose(const double inElements[16], double outElements[16]); 00116 //ETX 00117 00119 00121 void MultiplyPoint(const float in[4], float out[4]) 00122 {vtkMatrix4x4::MultiplyPoint(*this->Element,in,out); } 00123 void MultiplyPoint(const double in[4], double out[4]) 00124 {vtkMatrix4x4::MultiplyPoint(*this->Element,in,out); } 00126 00127 //BTX 00128 static void MultiplyPoint(const double Elements[16], 00129 const float in[4], float out[4]); 00130 static void MultiplyPoint(const double Elements[16], 00131 const double in[4], double out[4]); 00132 //ETX 00133 00135 00137 float *MultiplyPoint(const float in[4]) 00138 {return this->MultiplyFloatPoint(in); } 00139 float *MultiplyFloatPoint(const float in[4]) 00140 {this->MultiplyPoint(in,this->FloatPoint); return this->FloatPoint; } 00141 double *MultiplyDoublePoint(const double in[4]) 00142 {this->MultiplyPoint(in,this->DoublePoint); return this->DoublePoint; } 00144 00146 00147 static void Multiply4x4(vtkMatrix4x4 *a, vtkMatrix4x4 *b, vtkMatrix4x4 *c) { 00148 vtkMatrix4x4::Multiply4x4(*a->Element,*b->Element,*c->Element); }; 00150 //BTX 00151 static void Multiply4x4(const double a[16], const double b[16], 00152 double c[16]); 00153 //ETX 00154 00156 00157 void Adjoint(vtkMatrix4x4 *in, vtkMatrix4x4 *out) 00158 {vtkMatrix4x4::Adjoint(*in->Element,*out->Element);} 00160 //BTX 00161 static void Adjoint(const double inElements[16], double outElements[16]); 00162 //ETX 00163 00165 double Determinant() {return vtkMatrix4x4::Determinant(*this->Element);} 00166 //BTX 00167 static double Determinant(const double Elements[16]); 00168 //ETX 00169 00171 void SetElement(int i, int j, double value); 00172 00174 00175 double GetElement(int i, int j) const 00176 {return this->Element[i][j];} 00178 00179 //BTX 00180 double *operator[](const unsigned int i) 00181 {return &(this->Element[i][0]);} 00182 const double *operator[](unsigned int i) const 00183 { return &(this->Element[i][0]); } 00184 void Adjoint(vtkMatrix4x4 &in,vtkMatrix4x4 &out) 00185 {this->Adjoint(&in,&out);} 00186 double Determinant(vtkMatrix4x4 &in) 00187 {return this->Determinant(&in);} 00188 double Determinant(vtkMatrix4x4 *in) 00189 {return vtkMatrix4x4::Determinant(*in->Element);} 00190 void Invert(vtkMatrix4x4 &in,vtkMatrix4x4 &out) 00191 {this->Invert(&in,&out);} 00192 void Transpose(vtkMatrix4x4 &in,vtkMatrix4x4 &out) 00193 {this->Transpose(&in,&out);} 00194 static void PointMultiply(const double Elements[16], 00195 const float in[4], float out[4]); 00196 static void PointMultiply(const double Elements[16], 00197 const double in[4], double out[4]); 00198 //ETX 00199 00200 protected: 00201 vtkMatrix4x4() { vtkMatrix4x4::Identity(*this->Element); }; 00202 ~vtkMatrix4x4() {}; 00203 00204 float FloatPoint[4]; 00205 double DoublePoint[4]; 00206 private: 00207 vtkMatrix4x4(const vtkMatrix4x4&); // Not implemented 00208 void operator= (const vtkMatrix4x4&); // Not implemented 00209 }; 00210 00211 inline void vtkMatrix4x4::SetElement(int i, int j, double value) 00212 { 00213 if (this->Element[i][j] != value) 00214 { 00215 this->Element[i][j] = value; 00216 this->Modified(); 00217 } 00218 } 00219 00220 #endif 00221