GlPortal Class Reference  0.1.1
Source code documentation of the free and open 3D action puzzle game.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Matrix3f.hpp
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------------
2 ** This software is in the public domain, furnished "as is", without technical
3 ** support, and with no warranty, express or implied, as to its usefulness for
4 ** any purpose.
5 **
6 ** Matrix3f.hpp
7 ** Declares a 3x3 matrix consisting of 9 float values and its helper functions
8 **
9 ** Author: Nim
10 ** -------------------------------------------------------------------------*/
11 
12 #pragma once
13 #ifndef MATRIX3F_HPP
14 #define MATRIX3F_HPP
15 
16 #include <string>
17 
18 namespace radix {
19 
20 class Matrix4f;
21 class Vector3f;
22 class Vector2f;
23 
24 class Matrix3f {
25 public:
26  static const Matrix3f Identity;
27 
28  /* Core */
29  Matrix3f();
30  void setIdentity();
31  void translate(const Vector2f &v);
32  void rotate(float angle);
33  void scale(float scale);
34  void scale(const Vector2f &scale);
35  Vector3f transform(const Vector3f &v) const;
36 
37  float* toArray();
38  std::string str() const;
39 
40  /* Operator overloads */
41  inline float operator[](int i) const {
42  return a[i];
43  }
44  inline float& operator[](int i) {
45  return a[i];
46  }
47  bool operator==(const Matrix3f&) const;
48  bool operator!=(const Matrix3f&) const;
49  Matrix3f operator*(const Matrix3f&) const;
50 private:
51  float a[9];
52 };
53 
54 /* Utility functions */
55 Matrix3f transpose(const Matrix3f& m);
56 float determinant(const Matrix3f& m);
57 Matrix3f inverse(const Matrix3f& m);
58 Matrix4f toMatrix4f(const Matrix3f& m);
59 
60 } /* namespace radix */
61 
62 #endif /* MATRIX3F_HPP */
float * toArray()
Definition: Matrix3f.cpp:87
Definition: GameController.hpp:7
Definition: Matrix3f.hpp:24
Matrix3f operator*(const Matrix3f &) const
Definition: Matrix3f.cpp:110
static const Matrix3f Identity
Definition: Matrix3f.hpp:26
Matrix3f inverse(const Matrix3f &m)
Definition: Matrix3f.cpp:150
void scale(float scale)
Definition: Matrix3f.cpp:58
float operator[](int i) const
Definition: Matrix3f.hpp:41
2-dimensional float-based vector/point storage and manipulation struct
Definition: Vector2f.hpp:23
bool operator!=(const Matrix3f &) const
Definition: Matrix3f.cpp:106
float & operator[](int i)
Definition: Matrix3f.hpp:44
Vector3f transform(const Vector3f &v) const
Definition: Matrix3f.cpp:79
Matrix4f toMatrix4f(const Matrix3f &m)
Definition: Matrix3f.cpp:169
void translate(const Vector2f &v)
Definition: Matrix3f.cpp:42
Matrix3f transpose(const Matrix3f &m)
Definition: Matrix3f.cpp:128
float a[9]
Definition: Matrix3f.hpp:51
void setIdentity()
Definition: Matrix3f.cpp:38
Definition: Matrix4f.hpp:25
Matrix3f()
Definition: Matrix3f.cpp:34
std::string str() const
Definition: Matrix3f.cpp:91
bool operator==(const Matrix3f &) const
Definition: Matrix3f.cpp:102
float determinant(const Matrix3f &m)
Definition: Matrix3f.cpp:142
void rotate(float angle)
Definition: Matrix3f.cpp:48
3-dimensional float-based vector/point storage and manipulation struct
Definition: Vector3f.hpp:27