home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / graphtal / trnsmtrx.h < prev    next >
C/C++ Source or Header  |  1992-10-19  |  2KB  |  77 lines

  1. /*
  2.  * TransMatrix.h - class definition for general 4x3 transformation matrices.
  3.  *
  4.  * Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  *
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  */
  17.  
  18. #ifndef TransMatrix_H
  19. # define TransMatrix_H
  20.  
  21. #include <iostream.h>
  22. #include "Globals.h"
  23. #include "Vector.h"
  24.  
  25. void SinCos(real alpha, real&, real&);
  26.  
  27. //___________________________________________________________ TransMatrix
  28. /*
  29.  *  [ m11 m12 m13 0 ]   
  30.  *  [ m21 m22 m23 0 ]   representation of a 
  31.  *  [ m31 m32 m33 0 ]   transformation matrix
  32.  *  [ m41 m42 m43 1 ]
  33.  */
  34.  
  35. class TransMatrix
  36. {
  37. public:
  38.   enum Axis {X, Y, Z};
  39.  
  40. public:
  41.   TransMatrix();
  42.   TransMatrix(const Vector&, const Vector&, const Vector&);
  43.   TransMatrix(const Vector&, const Vector&, const Vector&, const Vector&);
  44.   TransMatrix(const TransMatrix&);
  45.  
  46.   const TransMatrix& operator=(const TransMatrix&);
  47.   
  48.   real& operator()(int i, int j);
  49.   real  operator()(int i, int j) const;
  50.  
  51.   TransMatrix& operator+=(const TransMatrix&);
  52.   TransMatrix& operator-=(const TransMatrix&);
  53.   TransMatrix& operator*=(const TransMatrix&);
  54.  
  55.   TransMatrix operator-();   
  56.   TransMatrix operator+(const TransMatrix&);
  57.   TransMatrix operator-(const TransMatrix&);
  58.   TransMatrix operator*(const TransMatrix&);
  59.  
  60.   int invert();
  61.   void setRotate(const Vector&, real);
  62.   TransMatrix& rotate(const Vector&, real);
  63.   TransMatrix& rotate(Axis, const real, const real);
  64.   TransMatrix& rotate(Axis, const real);
  65.   TransMatrix& scale(const real, const real, const real);
  66.   TransMatrix& translate(const Vector&);
  67.  
  68.   friend ostream& operator<<(ostream&, const TransMatrix&);
  69.   friend Vector operator*(const Vector&, const TransMatrix&);
  70.    
  71. private:
  72.   real m[4][3];
  73. };
  74.  
  75.  
  76. #endif // TransMatrix_H
  77.