All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2  * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3  *
4  * zenilib is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * zenilib is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16  */
36 #ifndef ZENI_MATRIX_H
37 #define ZENI_MATRIX_H
39 #include <Zeni/Serialization.h>
40 #include <Zeni/Vector3f.h>
41 #include <vector>
43 namespace Zeni {
45  struct ZENI_DLL Quaternion;
47  class ZENI_DLL Matrix4f {
48  public:
49  class ZENI_DLL Matrix4f_Row {
50  public:
51  inline Matrix4f_Row(float * const &row_);
53  inline const float & operator[](const int &index) const;
54  inline float & operator[](const int &index);
56  private:
57  float *row;
58  };
60  Matrix4f();
61  Matrix4f(
62  const float &aw, const float &ax, const float &ay, const float &az,
63  const float &bw, const float &bx, const float &by, const float &bz,
64  const float &cw, const float &cx, const float &cy, const float &cz,
65  const float &dw, const float &dx, const float &dy, const float &dz);
66  Matrix4f(const Vector3f &first, const Vector3f &second, const Vector3f &third, const bool &rows = false);
67  Matrix4f(const Matrix4f &rhs);
69  // Indexing
70  inline const Matrix4f_Row operator[](const int &index) const;
71  inline Matrix4f_Row operator[](const int &index);
73  // Fundamental Matrix Constructors
74  inline static Matrix4f Zero();
75  inline static Matrix4f Identity();
76  inline static Matrix4f Scale(const Vector3f &scaling_factor);
77  inline static Matrix4f Rotate(const Quaternion &rotation);
78  inline static Matrix4f Translate(const Vector3f &translation_factor);
80  inline static Matrix4f View(const Point3f &position, const Vector3f &forward, const Vector3f &up);
82  inline static Matrix4f Orthographic(const float &left, const float &right, const float &bottom, const float &top, const float &near, const float &far);
84  inline static Matrix4f Perspective(const float &fov_rad_y, const float &aspect, const float &near, const float &far);
86  inline static Matrix4f Frustum(const Point2f &upper_left, const Point2f &lower_right, const float &near, const float &far);
88  // Matrix addition/subtraction
89  inline Matrix4f operator+(const Matrix4f &rhs) const;
90  inline Matrix4f operator-(const Matrix4f &rhs) const;
91  inline Matrix4f & operator+=(const Matrix4f &rhs);
92  inline Matrix4f & operator-=(const Matrix4f &rhs);
94  // Matrix Products
95  inline Matrix4f operator*(const Matrix4f &rhs) const;
96  inline Matrix4f operator*=(const Matrix4f &rhs);
97  inline Matrix4f operator/(const Matrix4f &rhs) const;
98  inline Matrix4f operator/=(const Matrix4f &rhs);
100  // Matrix Scalar Operations
101  inline Matrix4f operator*(const float &rhs) const;
102  inline Matrix4f operator/(const float &rhs) const;
103  inline Matrix4f & operator*=(const float &rhs);
104  inline Matrix4f & operator/=(const float &rhs);
105  inline Matrix4f operator-() const;
107  // Other Standard Functions
108  Matrix4f & invert();
109  Matrix4f inverted() const;
110  Matrix4f & transpose();
111  Matrix4f transposed() const;
112  float determinant() const;
114  // Vector Functions
115  inline Vector3f get_column(const int &column) const;
116  inline Vector3f get_row(const int &row) const;
117  Vector3f operator*(const Vector3f &vector) const;
119  private:
120  float m_matrix[4][4];
121  };
123  ZENI_DLL std::ostream & serialize(std::ostream &os, const Matrix4f &value);
124  ZENI_DLL std::istream & unserialize(std::istream &is, Matrix4f &value);
126 }
128 #endif
GLint GLint bottom
Definition: glew.h:7291
GLint left
Definition: glew.h:7291
GLboolean invert
Definition: glew.h:1408
TiXmlString operator+(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.cpp:86
Quaternion operator/(const float &lhs, const Quaternion &rhs)
Definition: Quaternion.h:114
std::istream & unserialize(std::istream &is, Color &value)
Definition: Color.cpp:72
GLdouble far
Definition: glcorearb.h:138
std::ostream & serialize(std::ostream &os, const Color &value)
Definition: Color.cpp:68
GLint GLsizei GLboolean transpose
Definition: gl2ext.h:1228
A 3D Point represented with floats.
Definition: Coordinate.h:133
A Featureful 3-Space Vector Class.
Definition: Vector3f.h:58
GLenum GLenum GLvoid * row
Definition: glew.h:4447
GLint first
Definition: gl2ext.h:1011
GLbyte by
Definition: SDL_opengl.h:8286
A Featureful Quaternion Class.
Definition: Quaternion.h:44
GLenum GLenum GLvoid GLvoid * column
Definition: glew.h:4447
GLuint index
Definition: glew.h:1800
Quaternion operator*(const float &lhs, const Quaternion &rhs)
Definition: Quaternion.h:110
GLfloat GLfloat GLfloat top
Definition: glew.h:13816
GLbyte GLbyte bz
Definition: SDL_opengl.h:8286
EGLSurface EGLint void ** value
Definition: eglext.h:301
A Featureful 4-Space Matrix Class.
Definition: Matrix4f.h:47
GLfloat right
Definition: glew.h:13816
A 2D Point represented with floats.
Definition: Coordinate.h:98