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

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 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 
00039 =========================================================================*/
00056 #ifndef __vtkMatrix4x4_h
00057 #define __vtkMatrix4x4_h
00058 
00059 #include "vtkObject.h"
00060 
00061 class VTK_EXPORT vtkMatrix4x4 : public vtkObject
00062 {
00063   // Some of the methods in here have a corresponding static (class)
00064   // method taking a pointer to 16 doubles that constitutes a user
00065   // supplied matrix. This allows C++ clients to allocate double arrays
00066   // on the stack and manipulate them using vtkMatrix4x4 methods. 
00067   // This is an alternative to allowing vtkMatrix4x4 instances to be
00068   // created on the stack (which is frowned upon) or doing lots of
00069   // temporary heap allocation within vtkTransform and vtkActor methods,
00070   // which is inefficient.
00071 
00072 public:
00073   double Element[4][4];
00074 
00076   static vtkMatrix4x4 *New();
00077 
00078   vtkTypeMacro(vtkMatrix4x4,vtkObject);
00079   void PrintSelf(ostream& os, vtkIndent indent);
00080   
00083   void DeepCopy(vtkMatrix4x4 *source) 
00084     {vtkMatrix4x4::DeepCopy(*this->Element,source); this->Modified(); }
00085 //BTX
00086   static void DeepCopy(double Elements[16], vtkMatrix4x4 *source) 
00087     {vtkMatrix4x4::DeepCopy(Elements,*source->Element); }
00088   static void DeepCopy(double Elements[16], const double newElements[16]);
00089 //ETX
00090 
00092   void DeepCopy(const double Elements[16]) 
00093     { this->DeepCopy(*this->Element,Elements); this->Modified(); }
00094 
00096   void Zero() 
00097     { vtkMatrix4x4::Zero(*this->Element); this->Modified(); }
00098 //BTX
00099   static void Zero(double Elements[16]);
00100 //ETX  
00101 
00103   void Identity() 
00104     { vtkMatrix4x4::Identity(*this->Element); this->Modified();}
00105 //BTX
00106   static void Identity(double Elements[16]);
00107 //ETX  
00108 
00111   static void Invert(vtkMatrix4x4 *in, vtkMatrix4x4 *out) 
00112     {vtkMatrix4x4::Invert(*in->Element,*out->Element); out->Modified(); }
00113   void Invert() 
00114     { vtkMatrix4x4::Invert(this,this); }
00115 //BTX
00116   static void Invert(const double inElements[16], double outElements[16]);
00117 //ETX
00118 
00119 
00121   static void Transpose(vtkMatrix4x4 *in, vtkMatrix4x4 *out) 
00122     {vtkMatrix4x4::Transpose(*in->Element,*out->Element); out->Modified(); }
00123   void Transpose() 
00124     { vtkMatrix4x4::Transpose(this,this); }
00125 //BTX
00126   static void Transpose(const double inElements[16], double outElements[16]);
00127 //ETX
00128 
00131   void MultiplyPoint(const float in[4], float out[4]) 
00132     {vtkMatrix4x4::MultiplyPoint(*this->Element,in,out); }
00133   void MultiplyPoint(const double in[4], double out[4]) 
00134     {vtkMatrix4x4::MultiplyPoint(*this->Element,in,out); }
00135 
00136 //BTX
00137   static void MultiplyPoint(const double Elements[16], 
00138              const float in[4], float out[4]);
00139   static void MultiplyPoint(const double Elements[16], 
00140              const double in[4], double out[4]);
00141 //ETX
00142 
00145   float *MultiplyPoint(const float in[4]) 
00146     {return this->MultiplyFloatPoint(in); }
00147   float *MultiplyFloatPoint(const float in[4]) 
00148     {this->MultiplyPoint(in,this->FloatPoint); return this->FloatPoint; } 
00149   double *MultiplyDoublePoint(const double in[4]) 
00150     {this->MultiplyPoint(in,this->DoublePoint); return this->DoublePoint; } 
00151 
00153   static void Multiply4x4(vtkMatrix4x4 *a, vtkMatrix4x4 *b, vtkMatrix4x4 *c) {
00154     vtkMatrix4x4::Multiply4x4(*a->Element,*b->Element,*c->Element); };
00155 //BTX
00156   static void Multiply4x4(const double a[16], const double b[16], 
00157            double c[16]);
00158 //ETX
00159 
00161   void Adjoint(vtkMatrix4x4 *in, vtkMatrix4x4 *out) 
00162     {vtkMatrix4x4::Adjoint(*in->Element,*out->Element);}
00163 //BTX
00164   static void Adjoint(const double inElements[16], double outElements[16]);
00165 //ETX
00166 
00168   double Determinant() {return vtkMatrix4x4::Determinant(*this->Element);}
00169 //BTX
00170   static double Determinant(const double Elements[16]);
00171 //ETX
00172 
00174   void SetElement(int i, int j, double value);
00175 
00177   double GetElement(int i, int j) const 
00178     {return this->Element[i][j];}
00179 
00181   void PointMultiply(const float in[4], float out[4]);
00182   void PointMultiply(const double in[4], double out[4]);
00183 //BTX
00184   double *operator[](const unsigned int i) 
00185     {return &(this->Element[i][0]);}
00186   const double *operator[](unsigned int i) const
00187     { return &(this->Element[i][0]); }  
00188   void operator= (double element);
00189   void Adjoint(vtkMatrix4x4 &in,vtkMatrix4x4 &out)
00190     {this->Adjoint(&in,&out);}
00191   double Determinant(vtkMatrix4x4 &in) 
00192     {return this->Determinant(&in);}
00193   double Determinant(vtkMatrix4x4 *in) 
00194     {return vtkMatrix4x4::Determinant(*in->Element);}
00195   void Invert(vtkMatrix4x4 &in,vtkMatrix4x4 &out)
00196     {this->Invert(&in,&out);}
00197   void Transpose(vtkMatrix4x4 &in,vtkMatrix4x4 &out)
00198     {this->Transpose(&in,&out);}
00199   static void PointMultiply(const double Elements[16], 
00200              const float in[4], float out[4]);
00201   static void PointMultiply(const double Elements[16], 
00202              const double in[4], double out[4]);
00203 //ETX
00204 
00205 protected:
00206   vtkMatrix4x4() { vtkMatrix4x4::Identity(*this->Element); };
00207   ~vtkMatrix4x4() {};
00208   vtkMatrix4x4(const vtkMatrix4x4&);
00209   void operator= (const vtkMatrix4x4& source);
00210   
00211   float FloatPoint[4];
00212   double DoublePoint[4];
00213 };
00214 
00215 inline void vtkMatrix4x4::SetElement(int i, int j, double value)
00216 {
00217   if (this->Element[i][j] != value)
00218     {
00219     this->Element[i][j] = value;
00220     this->Modified();
00221     }
00222 }
00223 
00224 #endif
00225 

Generated on Wed Nov 21 12:26:52 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001