Common/vtkMatrix4x4.h Source File

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   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 =========================================================================*/
    00047 #ifndef __vtkMatrix4x4_h
    00048 #define __vtkMatrix4x4_h
    00049
    00050 #include "vtkObject.h"
    00051
    00052 class VTK_COMMON_EXPORT vtkMatrix4x4 : public vtkObject
    00053 {
    00054   // Some of the methods in here have a corresponding static (class)
    00055   // method taking a pointer to 16 doubles that constitutes a user
    00056   // supplied matrix. This allows C++ clients to allocate double arrays
    00057   // on the stack and manipulate them using vtkMatrix4x4 methods.
    00058   // This is an alternative to allowing vtkMatrix4x4 instances to be
    00059   // created on the stack (which is frowned upon) or doing lots of
    00060   // temporary heap allocation within vtkTransform and vtkActor methods,
    00061   // which is inefficient.
    00062
    00063 public:
    00064   double Element[4][4];
    00065
    00067   static vtkMatrix4x4 *New();
    00068
    00069   vtkTypeRevisionMacro(vtkMatrix4x4,vtkObject);
    00070   void PrintSelf(ostream& os, vtkIndent indent);
    00071
    00073
    00075   void DeepCopy(vtkMatrix4x4 *source)
    00076     {vtkMatrix4x4::DeepCopy(*this->Element,source); this->Modified(); }
    00078 //BTX
    00079   static void DeepCopy(double Elements[16], vtkMatrix4x4 *source)
    00080     {vtkMatrix4x4::DeepCopy(Elements,*source->Element); }
    00081   static void DeepCopy(double Elements[16], const double newElements[16]);
    00082 //ETX
    00083
    00085
    00086   void DeepCopy(const double Elements[16])
    00087     { this->DeepCopy(*this->Element,Elements); this->Modified(); }
    00089
    00091
    00092   void Zero()
    00093     { vtkMatrix4x4::Zero(*this->Element); this->Modified(); }
    00095 //BTX
    00096   static void Zero(double Elements[16]);
    00097 //ETX
    00098
    00100
    00101   void Identity()
    00102     { vtkMatrix4x4::Identity(*this->Element); this->Modified();}
    00104 //BTX
    00105   static void Identity(double Elements[16]);
    00106 //ETX
    00107
    00109
    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); }
    00116 //BTX
    00117   static void Invert(const double inElements[16], double outElements[16]);
    00118 //ETX
    00119
    00120
    00122
    00123   static void Transpose(vtkMatrix4x4 *in, vtkMatrix4x4 *out)
    00124     {vtkMatrix4x4::Transpose(*in->Element,*out->Element); out->Modified(); }
    00125   void Transpose()
    00126     { vtkMatrix4x4::Transpose(this,this); }
    00128 //BTX
    00129   static void Transpose(const double inElements[16], double outElements[16]);
    00130 //ETX
    00131
    00133
    00135   void MultiplyPoint(const float in[4], float out[4])
    00136     {vtkMatrix4x4::MultiplyPoint(*this->Element,in,out); }
    00137   void MultiplyPoint(const double in[4], double out[4])
    00138     {vtkMatrix4x4::MultiplyPoint(*this->Element,in,out); }
    00140
    00141 //BTX
    00142   static void MultiplyPoint(const double Elements[16],
    00143                             const float in[4], float out[4]);
    00144   static void MultiplyPoint(const double Elements[16],
    00145                             const double in[4], double out[4]);
    00146 //ETX
    00147
    00149
    00151   float *MultiplyPoint(const float in[4])
    00152     {return this->MultiplyFloatPoint(in); }
    00153   float *MultiplyFloatPoint(const float in[4])
    00154     {this->MultiplyPoint(in,this->FloatPoint); return this->FloatPoint; }
    00155   double *MultiplyDoublePoint(const double in[4])
    00156     {this->MultiplyPoint(in,this->DoublePoint); return this->DoublePoint; }
    00158
    00160
    00161   static void Multiply4x4(vtkMatrix4x4 *a, vtkMatrix4x4 *b, vtkMatrix4x4 *c) {
    00162     vtkMatrix4x4::Multiply4x4(*a->Element,*b->Element,*c->Element); };
    00164 //BTX
    00165   static void Multiply4x4(const double a[16], const double b[16],
    00166                           double c[16]);
    00167 //ETX
    00168
    00170
    00171   void Adjoint(vtkMatrix4x4 *in, vtkMatrix4x4 *out)
    00172     {vtkMatrix4x4::Adjoint(*in->Element,*out->Element);}
    00174 //BTX
    00175   static void Adjoint(const double inElements[16], double outElements[16]);
    00176 //ETX
    00177
    00179   double Determinant() {return vtkMatrix4x4::Determinant(*this->Element);}
    00180 //BTX
    00181   static double Determinant(const double Elements[16]);
    00182 //ETX
    00183
    00185   void SetElement(int i, int j, double value);
    00186
    00188
    00189   double GetElement(int i, int j) const
    00190     {return this->Element[i][j];}
    00192
    00193 //BTX
    00194   double *operator[](const unsigned int i)
    00195     {return &(this->Element[i][0]);}
    00196   const double *operator[](unsigned int i) const
    00197     { return &(this->Element[i][0]); }
    00198   void Adjoint(vtkMatrix4x4 &in,vtkMatrix4x4 &out)
    00199     {this->Adjoint(&in,&out);}
    00200   double Determinant(vtkMatrix4x4 &in)
    00201     {return this->Determinant(&in);}
    00202   double Determinant(vtkMatrix4x4 *in)
    00203     {return vtkMatrix4x4::Determinant(*in->Element);}
    00204   void Invert(vtkMatrix4x4 &in,vtkMatrix4x4 &out)
    00205     {this->Invert(&in,&out);}
    00206   void Transpose(vtkMatrix4x4 &in,vtkMatrix4x4 &out)
    00207     {this->Transpose(&in,&out);}
    00208   static void PointMultiply(const double Elements[16],
    00209                             const float in[4], float out[4]);
    00210   static void PointMultiply(const double Elements[16],
    00211                             const double in[4], double out[4]);
    00212 //ETX
    00213
    00214 protected:
    00215   vtkMatrix4x4() { vtkMatrix4x4::Identity(*this->Element); };
    00216   ~vtkMatrix4x4() {};
    00217
    00218   float FloatPoint[4];
    00219   double DoublePoint[4];
    00220 private:
    00221   vtkMatrix4x4(const vtkMatrix4x4&);  // Not implemented
    00222   void operator= (const vtkMatrix4x4&);  // Not implemented
    00223 };
    00224
    00225 inline void vtkMatrix4x4::SetElement(int i, int j, double value)
    00226 {
    00227   if (this->Element[i][j] != value)
    00228     {
    00229     this->Element[i][j] = value;
    00230     this->Modified();
    00231     }
    00232 }
    00233
    00234 #endif
    00235