Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 #ifndef VRML_MATRI4X4_H
00020 #define VRML_MATRI4X4_H
00021 
00022 #include <stdexcept>
00023 #include <iostream>
00024 
00025 #include "vector4.h"
00026 
00027 namespace vrml {
00028 
00032 class Matrix4x4
00033 {
00034   public:
00035     Matrix4x4();
00036     ~Matrix4x4();
00037 
00038     Matrix4x4(const Matrix4x4& other);
00039     explicit Matrix4x4(const double* data);
00040 
00045     void makeDiag(double d = 1.0);
00046 
00050     double* operator[](unsigned int m) throw (std::runtime_error)
00051     {
00052       if (m > 4)
00053         throw std::runtime_error("index exceeds matrix dimensions");
00054       return &_data[m*4];
00055     }
00056 
00060     const double* operator[](unsigned int m) const throw (std::runtime_error)
00061     {
00062       if (m > 4)
00063         throw std::runtime_error("index exceeds matrix dimensions");
00064       return &_data[m*4];
00065     }
00066     Matrix4x4& operator=(const Matrix4x4& other);
00068     Matrix4x4 operator* (const Matrix4x4& other) const;
00070     Vector4 operator* (const Vector4& vec) const;
00071 
00075     static Matrix4x4 translate(double dx, double dy, double dz);
00076 
00083     static Matrix4x4 rotate(double phi, double u, double v, double w);
00084 
00088     static Matrix4x4 scale(double sx, double sy, double sz);
00092     static Matrix4x4 identity();
00093 
00094   protected:
00096     void copy(const Matrix4x4& other);
00097     double _data[16]; 
00098 };
00099 
00100 std::ostream &operator<<(std::ostream &stream, const Matrix4x4& mat);
00101 
00102 }
00103 
00104 #endif