Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

Matrix44.h

00001 /*************************************************************************** 00002 * This file is part of OpenCAL: Open Computer Animation Library * 00003 * I created OpenCAL as my master's thesis Computer Science (multimedia) * 00004 * at the tUL university in Diepenbeek, Belgium * 00005 * * 00006 * Copyright (C) 2003-2004 by Jeroen Dierckx * 00007 * jeroen.dierckx@student.luc.ac.be * 00008 * * 00009 ***************************************************************************/ 00010 00011 #ifndef OPENCAL_UTILS_MATRIX44_H 00012 #define OPENCAL_UTILS_MATRIX44_H 00013 00014 // Includes 00015 #include <OpenCAL/global.h> 00016 #include <OpenCAL/Vector3.h> 00017 00018 namespace OpenCAL 00019 { 00020 namespace Utils 00021 { 00026 class OPENCAL_API Matrix44 00027 { 00028 protected: 00029 // Member variables 00030 float m_values[16]; 00031 00032 public: 00033 // Static member variables 00034 static const Matrix44 zero; 00035 static const Matrix44 unity; 00036 00037 public: 00038 // Constructors and destructor 00039 Matrix44(); 00040 Matrix44(const Matrix44 &source); 00041 virtual ~Matrix44(); 00042 00043 // Get functions 00044 const float *get() const { return m_values; } 00045 float get(int index) const { return m_values[index]; } 00046 float get(int row, int col) const { return m_values[4 * row + col]; } 00047 00048 // Set functions 00049 void set(float *values); 00050 void set(int index, float value) { m_values[index] = value; } 00051 void set(int row, int col, float value) { m_values[4 * row + col] = value; } 00052 00053 // Operator functions 00054 void operator=(const Matrix44 &m); // Assignment 00055 Matrix44 operator*(const Matrix44 &m) const; // Matrix product 00056 Matrix44 operator*(float factor) const; // Scalar product 00057 Vector3 operator*(const Vector3 &v) const; // Vector product 00058 Matrix44 operator+(const Matrix44 &m) const; // Matrix addition 00059 Matrix44 operator-() const; // Negation 00060 00061 bool operator==(const Matrix44 &m) const; // Equality 00062 bool operator!=(const Matrix44 &m) const // Not equality 00063 {return !(*this == m);} 00064 00065 // Transform functions 00066 void translate(const Vector3 &translation); 00067 void rotateX(float angle); 00068 void rotateY(float angle); 00069 void rotateZ(float angle); 00070 00071 // Other functions 00072 void identity(); // Creates the identity matrix 00073 //void zero(); // Clears the matrix 00074 void transpose(); // Transposes the matrix 00075 Matrix44 transposed(); // Returns the transposed of this matrix 00076 void fill(float value); // Fills the matrix with a value 00077 00078 void print(); // Prints out the matrix 00079 00080 protected: 00081 // This constructor is solely to construct the static members 00082 Matrix44( 00083 float m11, float m12, float m13, float m14, 00084 float m21, float m22, float m23, float m24, 00085 float m31, float m32, float m33, float m34, 00086 float m41, float m42, float m43, float m44); 00087 00088 // Friend functions 00089 friend Matrix44 operator*(float factor, const Matrix44 &m); // Scalar product 00090 }; 00091 } 00092 } 00093 00094 #endif // OPENCAL_UTILS_MATRIX44_H

Generated on Sun Aug 15 19:19:22 2004 for OpenCAL: Open Computer Animation Library by doxygen 1.3.8