volmetrics

annotate src/matrix.h @ 15:a93c8aa85e05

changed win title :p
author Eleni Maria Stea <elene.mst@gmail.com>
date Mon, 03 Feb 2014 01:30:47 +0200
parents
children
rev   line source
eleni@0 1 #ifndef MATRIX_H_
eleni@0 2 #define MATRIX_H_
eleni@0 3
eleni@0 4 #include <iostream>
eleni@0 5 #include "vector.h"
eleni@0 6
eleni@0 7 class Matrix4x4 {
eleni@0 8 public:
eleni@0 9 float m[4][4];
eleni@0 10
eleni@0 11 static Matrix4x4 identity;
eleni@0 12
eleni@0 13 Matrix4x4();
eleni@0 14 Matrix4x4( float m11, float m12, float m13, float m14,
eleni@0 15 float m21, float m22, float m23, float m24,
eleni@0 16 float m31, float m32, float m33, float m34,
eleni@0 17 float m41, float m42, float m43, float m44);
eleni@0 18
eleni@0 19 /* binary operations matrix (op) matrix */
eleni@0 20 friend Matrix4x4 operator +(const Matrix4x4 &m1, const Matrix4x4 &m2);
eleni@0 21 friend Matrix4x4 operator -(const Matrix4x4 &m1, const Matrix4x4 &m2);
eleni@0 22 friend Matrix4x4 operator *(const Matrix4x4 &m1, const Matrix4x4 &m2);
eleni@0 23
eleni@0 24 friend void operator +=(Matrix4x4 &m1, const Matrix4x4 &m2);
eleni@0 25 friend void operator -=(Matrix4x4 &m1, const Matrix4x4 &m2);
eleni@0 26 friend inline void operator *=(Matrix4x4 &m1, const Matrix4x4 &m2);
eleni@0 27
eleni@0 28 /* binary operations matrix (op) scalar and scalar (op) matrix */
eleni@0 29 friend Matrix4x4 operator *(const Matrix4x4 &mat, float scalar);
eleni@0 30 friend Matrix4x4 operator *(float scalar, const Matrix4x4 &mat);
eleni@0 31
eleni@0 32 friend void operator *=(Matrix4x4 &mat, float scalar);
eleni@0 33
eleni@0 34 inline float *operator [](int index);
eleni@0 35 inline const float *operator [](int index) const;
eleni@0 36
eleni@0 37 inline void reset_identity();
eleni@0 38
eleni@0 39 void translate(const Vector3 &trans);
eleni@0 40 void set_translation(const Vector3 &trans);
eleni@0 41
eleni@0 42 void rotate(const Vector3 &euler); /* 3d rotation with euler angles */
eleni@0 43 void rotate(const Vector3 &axis, float angle); /* 3d axis/angle rotation */
eleni@0 44 void set_rotation(const Vector3 &euler_angles);
eleni@0 45 void set_rotation(const Vector3 &axis, float angle);
eleni@0 46
eleni@0 47 void scale(const Vector3 &scale_vec);
eleni@0 48 void set_scaling(const Vector3 &scale_vec);
eleni@0 49
eleni@0 50 void set_column_vector(const Vector3 &vec, unsigned int col_index);
eleni@0 51 void set_row_vector(const Vector3 &vec, unsigned int row_index);
eleni@0 52 Vector3 get_column_vector(unsigned int col_index) const;
eleni@0 53 Vector3 get_row_vector(unsigned int row_index) const;
eleni@0 54
eleni@0 55 void transpose();
eleni@0 56 Matrix4x4 transposed() const;
eleni@0 57 float determinant() const;
eleni@0 58 Matrix4x4 adjoint() const;
eleni@0 59 Matrix4x4 inverse() const;
eleni@0 60 };
eleni@0 61
eleni@0 62 /* binary operations matrix (op) matrix */
eleni@0 63 Matrix4x4 operator +(const Matrix4x4 &m1, const Matrix4x4 &m2);
eleni@0 64 Matrix4x4 operator -(const Matrix4x4 &m1, const Matrix4x4 &m2);
eleni@0 65 Matrix4x4 operator *(const Matrix4x4 &m1, const Matrix4x4 &m2);
eleni@0 66
eleni@0 67 void operator +=(Matrix4x4 &m1, const Matrix4x4 &m2);
eleni@0 68 void operator -=(Matrix4x4 &m1, const Matrix4x4 &m2);
eleni@0 69 inline void operator *=(Matrix4x4 &m1, const Matrix4x4 &m2);
eleni@0 70
eleni@0 71 /* binary operations matrix (op) scalar and scalar (op) matrix */
eleni@0 72 Matrix4x4 operator *(const Matrix4x4 &mat, float scalar);
eleni@0 73 Matrix4x4 operator *(float scalar, const Matrix4x4 &mat);
eleni@0 74
eleni@0 75 void operator *=(Matrix4x4 &mat, float scalar);
eleni@0 76
eleni@0 77 std::ostream &operator <<(std::ostream &out, const Matrix4x4 &mat);
eleni@0 78
eleni@0 79
eleni@0 80 #endif
eleni@0 81