fart/util/Matrix.h
Josh Holtrop 2deee25004 added operator%() to util/Matrix
git-svn-id: svn://anubis/fart/trunk@30 7f9b0f55-74a9-4bce-be96-3c2cd072584d
2009-01-23 00:14:22 +00:00

36 lines
987 B
C++

#ifndef MATRIX_H
#define MATRIX_H MATRIX_H
#include "Vector.h"
#include <iostream>
class Matrix
{
public:
Matrix();
typedef double Matrix_row_t[4];
Matrix_row_t & operator[](int idx) { return m_matrix[idx]; }
const Matrix_row_t & operator[](int idx) const { return m_matrix[idx]; }
static Matrix identity();
double determinant();
Matrix getInverse();
Matrix & operator*=(const Matrix & other);
protected:
double m_matrix[4][4];
double m_inverse[4][4];
bool m_inverse_calculated;
bool m_inverse_valid;
void calculateInverse();
};
Matrix operator*(const Matrix & m1, const Matrix & m2);
Vector operator*(const Matrix & m, const Vector & v); /* transform point */
Vector operator%(const Matrix & m, const Vector & v); /* transform direction */
bool operator==(const Matrix & m1, const Matrix & m2);
std::ostream & operator<<(std::ostream & out, const Matrix & m);
#endif