Coin Logo http://www.sim.no
http://www.coin3d.org

SbDPMatrix.h

00001 #ifndef COIN_SBDPMATRIX_H
00002 #define COIN_SBDPMATRIX_H
00003 
00004 /**************************************************************************\
00005  *
00006  *  This file is part of the Coin 3D visualization library.
00007  *  Copyright (C) 1998-2007 by Systems in Motion.  All rights reserved.
00008  *
00009  *  This library is free software; you can redistribute it and/or
00010  *  modify it under the terms of the GNU General Public License
00011  *  ("GPL") version 2 as published by the Free Software Foundation.
00012  *  See the file LICENSE.GPL at the root directory of this source
00013  *  distribution for additional information about the GNU GPL.
00014  *
00015  *  For using Coin with software that can not be combined with the GNU
00016  *  GPL, and for taking advantage of the additional benefits of our
00017  *  support services, please contact Systems in Motion about acquiring
00018  *  a Coin Professional Edition License.
00019  *
00020  *  See http://www.coin3d.org/ for more information.
00021  *
00022  *  Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
00023  *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
00024  *
00025 \**************************************************************************/
00026 
00027 #include <stdio.h>
00028 #include <Inventor/SbBasic.h>
00029 
00030 class SbDPLine;
00031 class SbDPRotation;
00032 class SbVec3d;
00033 class SbVec4d;
00034 class SbMatrix;
00035 
00036 typedef double SbDPMat[4][4];
00037 
00038 class COIN_DLL_API SbDPMatrix {
00039 public:
00040   SbDPMatrix(void);
00041   SbDPMatrix(const double a11, const double a12, const double a13, const double a14,
00042              const double a21, const double a22, const double a23, const double a24,
00043              const double a31, const double a32, const double a33, const double a34,
00044              const double a41, const double a42, const double a43, const double a44);
00045   SbDPMatrix(const SbDPMat & matrix);
00046   SbDPMatrix(const SbDPMat * matrix);
00047   SbDPMatrix(const SbMatrix & matrix);
00048   ~SbDPMatrix(void);
00049 
00050   SbDPMatrix & operator =(const SbDPMat & m);
00051 
00052   operator double*(void);
00053   SbDPMatrix & operator =(const SbDPMatrix & m);
00054   void setValue(const SbDPMat & m);
00055   const SbDPMat & getValue(void) const;
00056 
00057   void makeIdentity(void);
00058   void setRotate(const SbDPRotation & q);
00059   SbDPMatrix inverse(void) const;
00060   double det3(int r1, int r2, int r3,
00061              int c1, int c2, int c3) const;
00062   double det3(void) const;
00063   double det4(void) const;
00064 
00065   SbBool equals(const SbDPMatrix & m, double tolerance) const;
00066 
00067 
00068   operator SbDPMat&(void);
00069   double * operator [](int i);
00070   const double * operator [](int i) const;
00071   SbDPMatrix & operator =(const SbDPRotation & q);
00072   SbDPMatrix & operator *=(const SbDPMatrix & m);
00073   friend COIN_DLL_API SbDPMatrix operator *(const SbDPMatrix & m1, const SbDPMatrix & m2);
00074   friend COIN_DLL_API int operator ==(const SbDPMatrix & m1, const SbDPMatrix & m2);
00075   friend COIN_DLL_API int operator !=(const SbDPMatrix & m1, const SbDPMatrix & m2);
00076   void getValue(SbDPMat & m) const;
00077   static SbDPMatrix identity(void);
00078   void setScale(const double s);
00079   void setScale(const SbVec3d & s);
00080   void setTranslate(const SbVec3d & t);
00081   void setTransform(const SbVec3d & t, const SbDPRotation & r, const SbVec3d & s);
00082   void setTransform(const SbVec3d & t, const SbDPRotation & r, const SbVec3d & s,
00083                     const SbDPRotation & so);
00084   void setTransform(const SbVec3d & translation,
00085                     const SbDPRotation & rotation, const SbVec3d & scaleFactor,
00086                     const SbDPRotation & scaleOrientation, const SbVec3d & center);
00087   void getTransform(SbVec3d & t, SbDPRotation & r,
00088                     SbVec3d & s, SbDPRotation & so) const;
00089   void getTransform(SbVec3d & translation, SbDPRotation & rotation,
00090                     SbVec3d & scaleFactor, SbDPRotation & scaleOrientation,
00091                     const SbVec3d & center) const;
00092   SbBool factor(SbDPMatrix & r, SbVec3d & s, SbDPMatrix & u, SbVec3d & t,
00093                 SbDPMatrix & proj);
00094   SbBool LUDecomposition(int index[4], double & d);
00095   void LUBackSubstitution(int index[4], double b[4]) const;
00096   SbDPMatrix transpose(void) const;
00097   SbDPMatrix & multRight(const SbDPMatrix & m);
00098   SbDPMatrix & multLeft(const SbDPMatrix & m);
00099   void multMatrixVec(const SbVec3d & src, SbVec3d & dst) const;
00100   void multVecMatrix(const SbVec3d & src, SbVec3d & dst) const;
00101   void multDirMatrix(const SbVec3d & src, SbVec3d & dst) const;
00102   void multLineMatrix(const SbDPLine & src, SbDPLine & dst) const;
00103   void multVecMatrix(const SbVec4d & src, SbVec4d & dst) const;
00104 
00105   void print(FILE * fp) const;
00106 
00107 private:
00108   double matrix[4][4];
00109 
00110   void operator /=(const double v);
00111   void operator *=(const double v);
00112 };
00113 
00114 COIN_DLL_API SbDPMatrix operator *(const SbDPMatrix & m1, const SbDPMatrix & m2);
00115 COIN_DLL_API int operator ==(const SbDPMatrix & m1, const SbDPMatrix & m2);
00116 COIN_DLL_API int operator !=(const SbDPMatrix & m1, const SbDPMatrix & m2);
00117 
00118 #endif // !COIN_SBDPMATRIX_H

Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.

Generated on Mon Feb 28 2011 10:11:52 for Coin by Doxygen. 1.7.3