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 =========================================================================*/
00057 #ifndef __vtkMatrix4x4_h
00058 #define __vtkMatrix4x4_h
00059 
00060 #include "vtkObject.h"
00061 
00062 class VTK_COMMON_EXPORT vtkMatrix4x4 : public vtkObject
00063 {
00064   // Some of the methods in here have a corresponding static (class)
00065   // method taking a pointer to 16 doubles that constitutes a user
00066   // supplied matrix. This allows C++ clients to allocate double arrays
00067   // on the stack and manipulate them using vtkMatrix4x4 methods. 
00068   // This is an alternative to allowing vtkMatrix4x4 instances to be
00069   // created on the stack (which is frowned upon) or doing lots of
00070   // temporary heap allocation within vtkTransform and vtkActor methods,
00071   // which is inefficient.
00072 
00073 public:
00074   double Element[4][4];
00075 
00077   static vtkMatrix4x4 *New();
00078 
00079   vtkTypeMacro(vtkMatrix4x4,vtkObject);
00080   void PrintSelf(ostream& os, vtkIndent indent);
00081   
00083 
00085   void DeepCopy(vtkMatrix4x4 *source) 
00086     {vtkMatrix4x4::DeepCopy(*this->Element,source); this->Modified(); }
00088 //BTX
00089   static void DeepCopy(double Elements[16], vtkMatrix4x4 *source) 
00090     {vtkMatrix4x4::DeepCopy(Elements,*source->Element); }
00091   static void DeepCopy(double Elements[16], const double newElements[16]);
00092 //ETX
00093 
00095 
00096   void DeepCopy(const double Elements[16]) 
00097     { this->DeepCopy(*this->Element,Elements); this->Modified(); }
00099 
00101 
00102   void Zero() 
00103     { vtkMatrix4x4::Zero(*this->Element); this->Modified(); }
00105 //BTX
00106   static void Zero(double Elements[16]);
00107 //ETX  
00108 
00110 
00111   void Identity() 
00112     { vtkMatrix4x4::Identity(*this->Element); this->Modified();}
00114 //BTX
00115   static void Identity(double Elements[16]);
00116 //ETX  
00117 
00119 
00121   static void Invert(vtkMatrix4x4 *in, vtkMatrix4x4 *out) 
00122     {vtkMatrix4x4::Invert(*in->Element,*out->Element); out->Modified(); }
00123   void Invert() 
00124     { vtkMatrix4x4::Invert(this,this); }
00126 //BTX
00127   static void Invert(const double inElements[16], double outElements[16]);
00128 //ETX
00129 
00130 
00132 
00133   static void Transpose(vtkMatrix4x4 *in, vtkMatrix4x4 *out) 
00134     {vtkMatrix4x4::Transpose(*in->Element,*out->Element); out->Modified(); }
00135   void Transpose() 
00136     { vtkMatrix4x4::Transpose(this,this); }
00138 //BTX
00139   static void Transpose(const double inElements[16], double outElements[16]);
00140 //ETX
00141 
00143 
00145   void MultiplyPoint(const float in[4], float out[4]) 
00146     {vtkMatrix4x4::MultiplyPoint(*this->Element,in,out); }
00147   void MultiplyPoint(const double in[4], double out[4]) 
00148     {vtkMatrix4x4::MultiplyPoint(*this->Element,in,out); }
00150 
00151 //BTX
00152   static void MultiplyPoint(const double Elements[16], 
00153                             const float in[4], float out[4]);
00154   static void MultiplyPoint(const double Elements[16], 
00155                             const double in[4], double out[4]);
00156 //ETX
00157 
00159 
00161   float *MultiplyPoint(const float in[4]) 
00162     {return this->MultiplyFloatPoint(in); }
00163   float *MultiplyFloatPoint(const float in[4]) 
00164     {this->MultiplyPoint(in,this->FloatPoint); return this->FloatPoint; } 
00165   double *MultiplyDoublePoint(const double in[4]) 
00166     {this->MultiplyPoint(in,this->DoublePoint); return this->DoublePoint; } 
00168 
00170 
00171   static void Multiply4x4(vtkMatrix4x4 *a, vtkMatrix4x4 *b, vtkMatrix4x4 *c) {
00172     vtkMatrix4x4::Multiply4x4(*a->Element,*b->Element,*c->Element); };
00174 //BTX
00175   static void Multiply4x4(const double a[16], const double b[16], 
00176                           double c[16]);
00177 //ETX
00178 
00180 
00181   void Adjoint(vtkMatrix4x4 *in, vtkMatrix4x4 *out) 
00182     {vtkMatrix4x4::Adjoint(*in->Element,*out->Element);}
00184 //BTX
00185   static void Adjoint(const double inElements[16], double outElements[16]);
00186 //ETX
00187 
00189   double Determinant() {return vtkMatrix4x4::Determinant(*this->Element);}
00190 //BTX
00191   static double Determinant(const double Elements[16]);
00192 //ETX
00193 
00195   void SetElement(int i, int j, double value);
00196 
00198 
00199   double GetElement(int i, int j) const 
00200     {return this->Element[i][j];}
00202 
00203 //BTX
00204   double *operator[](const unsigned int i) 
00205     {return &(this->Element[i][0]);}
00206   const double *operator[](unsigned int i) const
00207     { return &(this->Element[i][0]); }  
00208   void operator= (double element);
00209   void Adjoint(vtkMatrix4x4 &in,vtkMatrix4x4 &out)
00210     {this->Adjoint(&in,&out);}
00211   double Determinant(vtkMatrix4x4 &in) 
00212     {return this->Determinant(&in);}
00213   double Determinant(vtkMatrix4x4 *in) 
00214     {return vtkMatrix4x4::Determinant(*in->Element);}
00215   void Invert(vtkMatrix4x4 &in,vtkMatrix4x4 &out)
00216     {this->Invert(&in,&out);}
00217   void Transpose(vtkMatrix4x4 &in,vtkMatrix4x4 &out)
00218     {this->Transpose(&in,&out);}
00219   static void PointMultiply(const double Elements[16], 
00220                             const float in[4], float out[4]);
00221   static void PointMultiply(const double Elements[16], 
00222                             const double in[4], double out[4]);
00223 //ETX
00224 
00225 protected:
00226   vtkMatrix4x4() { vtkMatrix4x4::Identity(*this->Element); };
00227   ~vtkMatrix4x4() {};
00228   
00229   float FloatPoint[4];
00230   double DoublePoint[4];
00231 private:
00232   vtkMatrix4x4(const vtkMatrix4x4&);  // Not implemented.
00233   void operator= (const vtkMatrix4x4& source);  // Not implemented.
00234 };
00235 
00236 inline void vtkMatrix4x4::SetElement(int i, int j, double value)
00237 {
00238   if (this->Element[i][j] != value)
00239     {
00240     this->Element[i][j] = value;
00241     this->Modified();
00242     }
00243 }
00244 
00245 #endif
00246 

Generated on Thu Mar 28 14:19:16 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001