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

vtkMatrix4x4.h

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