CUGL 1.1
Cornell University Game Library
CUMat4.h
1 //
2 // CUMat4.h
3 // Cornell University Game Library (CUGL)
4 //
5 // This module provides support for a 4d matrix, which is the standard transform
6 // matrix in OpenGL. The class has support for basic camera creation, as well
7 // as the traditional transforms. It can transform any of Vec2, Vec3, and Vec4.
8 // Finally, there is vectorization support on select platforms.
9 //
10 // Because math objects are intended to be on the stack, we do not provide
11 // any shared pointer support in this class.
12 //
13 // This module is based on an original file from GamePlay3D: http://gameplay3d.org.
14 // It has been modified to support the CUGL framework.
15 //
16 // CUGL zlib License:
17 // This software is provided 'as-is', without any express or implied
18 // warranty. In no event will the authors be held liable for any damages
19 // arising from the use of this software.
20 //
21 // Permission is granted to anyone to use this software for any purpose,
22 // including commercial applications, and to alter it and redistribute it
23 // freely, subject to the following restrictions:
24 //
25 // 1. The origin of this software must not be misrepresented; you must not
26 // claim that you wrote the original software. If you use this software
27 // in a product, an acknowledgment in the product documentation would be
28 // appreciated but is not required.
29 //
30 // 2. Altered source versions must be plainly marked as such, and must not
31 // be misrepresented as being the original software.
32 //
33 // 3. This notice may not be removed or altered from any source distribution.
34 //
35 // Author: Walker White
36 // Version: 6/12/16
37 
38 #ifndef __CU_MAT4_H__
39 #define __CU_MAT4_H__
40 
41 // Vectorizaton support
42 #ifdef CU_MATH_VECTOR_APPLE
43  // Need this hack, because Apple dumps Size/Rect into empty namespace
44  #define VIMAGE_H
45  #include <Accelerate/Accelerate.h>
46 #endif
47  #ifdef CU_MATH_VECTOR_SSE
48  #include <xmmintrin.h>
49 #endif
50 
51 #if defined (__WINDOWS__)
52 #define NOMAXMIN
53 #endif
54 #include <math.h>
55 #include <assert.h>
56 #include "CUMathBase.h"
57 #include "CUVec2.h"
58 #include "CUVec3.h"
59 #include "CUVec4.h"
60 #include "CURect.h"
61 
62 namespace cugl {
63 
64 // Forward references
65 class Quaternion;
66 class Affine2;
67 
92 class Mat4 {
93 #pragma mark Values
94 public:
95 #if defined CU_MATH_VECTOR_APPLE
96  union {
97  vFloat col[4];
98  float m[16];
99  };
100 #elif defined CU_MATH_VECTOR_SSE
101  __declspec(align(16)) union {
102  __m128 col[4];
103  float m[16];
104  };
105 #else
106  float m[16];
107 #endif
108 
110  static const Mat4 ZERO;
112  static const Mat4 ONE;
114  static const Mat4 IDENTITY;
115 
116 
117 #pragma mark -
118 #pragma mark Constructors
119 public:
128  Mat4();
129 
150  Mat4(float m11, float m12, float m13, float m14,
151  float m21, float m22, float m23, float m24,
152  float m31, float m32, float m33, float m34,
153  float m41, float m42, float m43, float m44);
154 
168  Mat4(const float* mat);
169 
175  Mat4(const Mat4& copy);
176 
182  Mat4(Mat4&& copy);
183 
189  Mat4(const Quaternion& rotation) {
190  createRotation(rotation, this);
191  }
192 
196  ~Mat4() {}
197 
198 
199 #pragma mark -
200 #pragma mark Static Constructors
201 
210  static Mat4 createLookAt(const Vec3& eye, const Vec3& target, const Vec3& up) {
211  Mat4 result;
212  return *(createLookAt(eye,target,up,&result));
213  }
214 
215 
226  static Mat4* createLookAt(const Vec3& eye, const Vec3& target, const Vec3& up, Mat4* dst);
227 
243  static Mat4 createLookAt(float eyeX, float eyeY, float eyeZ,
244  float targetX, float targetY, float targetZ,
245  float upX, float upY, float upZ) {
246  Mat4 result;
247  return *(createLookAt(eyeX, eyeY, eyeZ,
248  targetX, targetY, targetZ,
249  upX, upY, upZ, &result));
250  }
251 
268  static Mat4* createLookAt(float eyeX, float eyeY, float eyeZ,
269  float targetX, float targetY, float targetZ,
270  float upX, float upY, float upZ, Mat4* dst);
271 
272 
290  static Mat4 createPerspective(float fieldOfView, float aspectRatio,
291  float zNearPlane, float zFarPlane) {
292  Mat4 result;
293  return *(createPerspective(fieldOfView, aspectRatio, zNearPlane, zFarPlane, &result));
294  }
295 
314  static Mat4* createPerspective(float fieldOfView, float aspectRatio,
315  float zNearPlane, float zFarPlane, Mat4* dst);
316 
342  static Mat4 createOrthographic(float width, float height,
343  float zNearPlane, float zFarPlane) {
344  Mat4 result;
345  return *(createOrthographic(width, height, zNearPlane, zFarPlane, &result));
346  }
347 
348 
375  static Mat4* createOrthographic(float width, float height,
376  float zNearPlane, float zFarPlane, Mat4* dst) {
377  float halfWidth = width / 2.0f;
378  float halfHeight = height / 2.0f;
379  return createOrthographicOffCenter(-halfWidth, halfWidth, -halfHeight, halfHeight,
380  zNearPlane, zFarPlane, dst);
381  }
382 
410  static Mat4 createOrthographicOffCenter(float left, float right, float bottom, float top,
411  float zNearPlane, float zFarPlane) {
412  Mat4 result;
413  return *(createOrthographicOffCenter(left, right, bottom, top, zNearPlane, zFarPlane, &result));
414  }
415 
416 
445  static Mat4* createOrthographicOffCenter(float left, float right, float bottom, float top,
446  float zNearPlane, float zFarPlane, Mat4* dst);
447 
455  static Mat4 createScale(float scale) {
456  Mat4 result;
457  return *(createScale(scale,&result));
458  }
459 
468  static Mat4* createScale(float scale, Mat4* dst);
469 
479  static Mat4 createScale(float sx, float sy, float sz) {
480  Mat4 result;
481  return *(createScale(sx,sy,sz,&result));
482  }
483 
494  static Mat4* createScale(float sx, float sy, float sz, Mat4* dst);
495 
503  static Mat4 createScale(const Vec3& scale) {
504  Mat4 result;
505  return *(createScale(scale,&result));
506  }
507 
516  static Mat4* createScale(const Vec3& scale, Mat4* dst);
517 
525  static Mat4 createRotation(const Quaternion& quat) {
526  Mat4 result;
527  return *(createRotation(quat,&result));
528  }
529 
538  static Mat4* createRotation(const Quaternion& quat, Mat4* dst);
539 
551  static Mat4 createRotation(const Vec3& axis, float angle) {
552  Mat4 result;
553  return *(createRotation(axis,angle,&result));
554  }
555 
568  static Mat4* createRotation(const Vec3& axis, float angle, Mat4* dst);
569 
580  static Mat4 createRotationX(float angle) {
581  Mat4 result;
582  return *(createRotationX(angle,&result));
583  }
584 
596  static Mat4* createRotationX(float angle, Mat4* dst);
597 
608  static Mat4 createRotationY(float angle) {
609  Mat4 result;
610  return *(createRotationY(angle,&result));
611  }
612 
624  static Mat4* createRotationY(float angle, Mat4* dst);
625 
636  static Mat4 createRotationZ(float angle) {
637  Mat4 result;
638  return *(createRotationZ(angle,&result));
639  }
640 
652  static Mat4* createRotationZ(float angle, Mat4* dst);
653 
661  static Mat4 createTranslation(const Vec3& trans) {
662  Mat4 result;
663  return *(createTranslation(trans,&result));
664  }
665 
674  static Mat4* createTranslation(const Vec3& trans, Mat4* dst);
675 
685  static Mat4 createTranslation(float tx, float ty, float tz) {
686  Mat4 result;
687  return *(createTranslation(tx,ty,tz,&result));
688  }
689 
700  static Mat4* createTranslation(float tx, float ty, float tz, Mat4* dst);
701 
702 
703 #pragma mark -
704 #pragma mark Setters
705 
712  Mat4& operator=(const Mat4& mat) {
713  return set(mat);
714  }
715 
723  Mat4& operator=(Mat4&& mat) {
724  memcpy(this->m, mat.m, sizeof(float)*16);
725  return *this;
726  }
727 
743  Mat4& operator=(const float* array) {
744  return set(array);
745  }
746 
754  Mat4& operator=(const Quaternion& quat) {
755  return set(quat);
756  }
757 
780  Mat4& set(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24,
781  float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44);
782 
798  Mat4& set(const float* mat);
799 
807  Mat4& set(const Quaternion& quat);
808 
816  Mat4& set(const Mat4& mat);
817 
823  Mat4& setIdentity();
824 
830  Mat4& setZero();
831 
832 
833 #pragma mark -
834 #pragma mark Static Arithmetic
835 
845  static Mat4* add(const Mat4& mat, float scalar, Mat4* dst);
846 
856  static Mat4* add(const Mat4& m1, const Mat4& m2, Mat4* dst);
857 
867  static Mat4* subtract(const Mat4& mat, float scalar, Mat4* dst);
868 
878  static Mat4* subtract(const Mat4& m1, const Mat4& m2, Mat4* dst);
879 
889  static Mat4* multiply(const Mat4& mat, float scalar, Mat4* dst);
890 
903  static Mat4* multiply(const Mat4& m1, const Mat4& m2, Mat4* dst);
904 
913  static Mat4* negate(const Mat4& m1, Mat4* dst);
914 
926  static Mat4* invert(const Mat4& m1, Mat4* dst);
927 
940  static Mat4* transpose(const Mat4& m1, Mat4* dst);
941 
942 #pragma mark -
943 #pragma mark Arithmetic
944 
951  Mat4& add(float scalar) {
952  return *(add(*this,scalar,this));
953  }
954 
962  Mat4& add(const Mat4& mat) {
963  return *(add(*this,mat,this));
964  }
965 
973  Mat4& subtract(float scalar) {
974  return *(subtract(*this,scalar,this));
975  }
976 
984  Mat4& subtract(const Mat4& mat) {
985  return *(subtract(*this,mat,this));
986  }
987 
995  Mat4& multiply(float scalar) {
996  return *(multiply(*this,scalar,this));
997  }
998 
1009  Mat4& multiply(const Mat4& mat) {
1010  return *(multiply(*this,mat,this));
1011  }
1012 
1019  return *(negate(*this,this));
1020  }
1021 
1029  Mat4 getNegation() const {
1030  Mat4 result;
1031  negate(*this,&result);
1032  return result;
1033  }
1034 
1044  return *(invert(*this,this));
1045  }
1046 
1056  Mat4 getInverse() const {
1057  Mat4 result;
1058  invert(*this,&result);
1059  return result;
1060  }
1061 
1072  return *(transpose(*this,this));
1073  }
1074 
1086  Mat4 getTranspose() const {
1087  Mat4 result;
1088  transpose(*this,&result);
1089  return result;
1090  }
1091 
1092 
1093 #pragma mark -
1094 #pragma mark Operators
1095 
1102  Mat4& operator+=(const Mat4& mat) {
1103  return add(mat);
1104  }
1105 
1113  Mat4& operator-=(const Mat4& mat) {
1114  return subtract(mat);
1115  }
1116 
1127  Mat4& operator*=(const Mat4& mat) {
1128  return multiply(mat);
1129  }
1130 
1138  Mat4& operator*=(float scalar) {
1139  return multiply(scalar);
1140  }
1141 
1151  const Mat4 operator+(const Mat4& mat) const {
1152  Mat4 result(*this);
1153  return result.add(mat);
1154  }
1155 
1165  const Mat4 operator-(const Mat4& mat) const {
1166  Mat4 result(*this);
1167  return result.subtract(mat);
1168  }
1169 
1177  const Mat4 operator-() const {
1178  return getNegation();
1179  }
1180 
1193  const Mat4 operator*(const Mat4& mat) const {
1194  Mat4 result(*this);
1195  return result.multiply(mat);
1196  }
1197 
1207  const Mat4 operator*(float scalar) const {
1208  Mat4 result(*this);
1209  return result.multiply(scalar);
1210  }
1211 
1212 
1213 #pragma mark -
1214 #pragma mark Comparisons
1215 
1226  bool isExactly(const Mat4& mat) const;
1227 
1238  bool equals(const Mat4& mat, float variance=CU_MATH_EPSILON) const;
1239 
1251  bool operator==(const Mat4& mat) const {
1252  return isExactly(mat);
1253  }
1254 
1265  bool operator!=(const Mat4& mat) const {
1266  return !isExactly(mat);
1267  }
1268 
1269 
1270 #pragma mark -
1271 #pragma mark Matrix Attributes
1272 
1283  bool isIdentity(float variance=0.0f) const;
1284 
1294  bool isInvertible(float variance=CU_MATH_EPSILON) const {
1295  return fabsf(getDeterminant()) > variance;
1296  }
1297 
1307  bool isOrthogonal(float variance=CU_MATH_EPSILON) const;
1308 
1314  float getDeterminant() const;
1315 
1330  Vec3 getScale() const;
1331 
1340  Quaternion getRotation() const;
1341 
1351  Vec3 getTranslation() const;
1352 
1358  Vec3 getUpVector() const;
1359 
1365  Vec3 getDownVector() const;
1371  Vec3 getLeftVector() const;
1372 
1378  Vec3 getRightVector() const;
1379 
1385  Vec3 getForwardVector() const;
1386 
1392  Vec3 getBackVector() const;
1393 
1394 
1395 #pragma mark -
1396 #pragma mark Static Vector Operations
1397 
1409  static Vec2* transform(const Mat4& mat, const Vec2& point, Vec2* dst);
1410 
1423  static Rect* transform(const Mat4& mat, const Rect& rect, Rect* dst);
1424 
1437  static Vec2* transformVector(const Mat4& mat, const Vec2& vec, Vec2* dst);
1438 
1451  static Vec3* transform(const Mat4& mat, const Vec3& point, Vec3* dst);
1452 
1465  static Vec3* transformVector(const Mat4& mat, const Vec3& vec, Vec3* dst);
1466 
1479  static Vec4* transform(const Mat4& mat, const Vec4& vec, Vec4* dst);
1480 
1481 
1482 #pragma mark -
1483 #pragma mark Vector Operations
1484 
1497  Vec2 transform(const Vec2& point) const;
1498 
1512  Rect transform(const Rect& rect) const;
1513 
1527  Vec2 transformVector(const Vec2& vec) const;
1528 
1542  Vec3 transform(const Vec3& point) const;
1543 
1557  Vec3 transformVector(const Vec3& vec) const;
1558 
1572  Vec4 transform(const Vec4& vec) const;
1573 
1574 #pragma mark -
1575 #pragma mark Static Matrix Transforms
1576 
1588  static Mat4* rotate(const Mat4& mat, const Quaternion& quat, Mat4* dst) {
1589  Mat4 result;
1590  createRotation(quat, &result);
1591  multiply(mat, result, dst);
1592  return dst;
1593  }
1594 
1610  static Mat4* rotate(const Mat4& mat, const Vec3& axis, float angle, Mat4* dst) {
1611  Mat4 result;
1612  createRotation(axis, angle, &result);
1613  multiply(mat, result, dst);
1614  return dst;
1615  }
1616 
1631  static Mat4* rotateX(const Mat4& mat, float angle, Mat4* dst) {
1632  Mat4 result;
1633  createRotationX(angle, &result);
1634  multiply(mat, result, dst);
1635  return dst;
1636  }
1637 
1652  static Mat4* rotateY(const Mat4& mat, float angle, Mat4* dst) {
1653  Mat4 result;
1654  createRotationY(angle, &result);
1655  multiply(mat, result, dst);
1656  return dst;
1657  }
1658 
1673  static Mat4* rotateZ(const Mat4& mat, float angle, Mat4* dst) {
1674  Mat4 result;
1675  createRotationZ(angle, &result);
1676  multiply(mat, result, dst);
1677  return dst;
1678  }
1679 
1692  static Mat4* scale(const Mat4& mat, float value, Mat4* dst) {
1693  Mat4 result;
1694  createScale(value, &result);
1695  multiply(mat, result, dst);
1696  return dst;
1697  }
1698 
1711  static Mat4* scale(const Mat4& mat, const Vec3& s, Mat4* dst) {
1712  Mat4 result;
1713  createScale(s, &result);
1714  multiply(mat, result, dst);
1715  return dst;
1716  }
1717 
1732  static Mat4* scale(const Mat4& mat, float sx, float sy, float sz, Mat4* dst) {
1733  Mat4 result;
1734  createScale(sx,sy,sz, &result);
1735  multiply(mat, result, dst);
1736  return dst;
1737  }
1738 
1751  static Mat4* translate(const Mat4& mat, const Vec3& t, Mat4* dst) {
1752  Mat4 result;
1753  createTranslation(t, &result);
1754  multiply(mat, result, dst);
1755  return dst;
1756  }
1757 
1772  static Mat4* translate(const Mat4& mat, float tx, float ty, float tz, Mat4* dst) {
1773  Mat4 result;
1774  createTranslation(tx,ty,tz, &result);
1775  multiply(mat, result, dst);
1776  return dst;
1777  }
1778 
1802  static bool decompose(const Mat4& mat, Vec3* scale, Quaternion* rot, Vec3* trans);
1803 
1804 
1805 #pragma mark -
1806 #pragma mark Matrix Transforms
1807 
1817  Mat4& rotate(const Quaternion& q) {
1818  return *(rotate(*this,q,this));
1819  }
1820 
1834  Mat4& rotate(const Vec3& axis, float angle) {
1835  return *(rotate(*this,axis,angle,this));
1836  }
1837 
1850  Mat4& rotateX(float angle) {
1851  return *(rotateX(*this,angle,this));
1852  }
1853 
1866  Mat4& rotateY(float angle) {
1867  return *(rotateY(*this,angle,this));
1868  }
1869 
1882  Mat4& rotateZ(float angle) {
1883  return *(rotateZ(*this,angle,this));
1884  }
1885 
1896  Mat4& scale(float value) {
1897  return *(scale(*this,value,this));
1898  }
1899 
1910  Mat4& scale(const Vec3& s) {
1911  return *(scale(*this,s,this));
1912  }
1913 
1926  Mat4& scale(float sx, float sy, float sz) {
1927  return *(scale(*this,sx,sy,sz,this));
1928  }
1929 
1940  Mat4& translate(const Vec3& t) {
1941  return *(translate(*this,t,this));
1942  }
1943 
1956  Mat4& translate(float tx, float ty, float tz) {
1957  return *(translate(*this,tx,ty,tz,this));
1958  }
1959 
1960 
1961 #pragma mark -
1962 #pragma mark Conversion Methods
1963 
1973  std::string toString(bool verbose = false) const;
1974 
1976  operator std::string() const { return toString(); }
1977 
1986  operator Affine2() const;
1987 
1995  explicit Mat4(const Affine2& aff);
1996 
2006  Mat4& operator= (const Affine2& aff);
2007 
2017  Mat4& set(const Affine2& aff);
2018 };
2019 
2020 #pragma mark -
2021 #pragma mark Vector Operations
2022 // To avoid confusion, we NEVER support vector on the right ops.
2023 
2035 inline Vec2& operator*=(Vec2& v, const Mat4& m) {
2036  return *(Mat4::transform(m,v,&v));
2037 }
2038 
2050 inline const Vec2 operator*(const Vec2& v, const Mat4& m) {
2051  return m.transform(v);
2052 }
2053 
2065 inline Vec3& operator*=(Vec3& v, const Mat4& m) {
2066  return *(Mat4::transform(m,v,&v));
2067 }
2068 
2080 inline const Vec3 operator*(const Vec3& v, const Mat4& m) {
2081  return m.transform(v);
2082 }
2083 
2095 inline Vec4& operator*=(Vec4& v, const Mat4& m) {
2096  return *(Mat4::transform(m,v,&v));
2097 }
2098 
2110 inline const Vec4 operator*(const Vec4& v, const Mat4& m) {
2111  return m.transform(v);
2112 }
2113 
2122 inline const Mat4 operator*(float scalar, const Mat4& m) {
2123  Mat4 result(m);
2124  return result.multiply(scalar);
2125 }
2126 
2127 }
2128 
2129 #endif /* __CU_MAT4_H__ */
static Mat4 createRotationX(float angle)
Definition: CUMat4.h:580
Vec3 getScale() const
Mat4 & set(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44)
bool isOrthogonal(float variance=CU_MATH_EPSILON) const
Mat4 & operator=(const Mat4 &mat)
Definition: CUMat4.h:712
Vec3 getTranslation() const
Vec3 getForwardVector() const
static Vec2 * transform(const Mat4 &mat, const Vec2 &point, Vec2 *dst)
static Mat4 * multiply(const Mat4 &mat, float scalar, Mat4 *dst)
Vec3 getBackVector() const
static Mat4 createRotation(const Vec3 &axis, float angle)
Definition: CUMat4.h:551
Vec2 & operator*=(Vec2 &v, const Affine2 &m)
Definition: CUAffine2.h:1165
Definition: CUVec2.h:61
Mat4(const Quaternion &rotation)
Definition: CUMat4.h:189
Definition: CUAffine2.h:63
float getDeterminant() const
Mat4 & operator=(Mat4 &&mat)
Definition: CUMat4.h:723
static Mat4 createScale(float sx, float sy, float sz)
Definition: CUMat4.h:479
static Mat4 createOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane)
Definition: CUMat4.h:410
Mat4 & scale(const Vec3 &s)
Definition: CUMat4.h:1910
Mat4 & scale(float value)
Definition: CUMat4.h:1896
~Mat4()
Definition: CUMat4.h:196
Mat4 & add(float scalar)
Definition: CUMat4.h:951
static Vec2 * transformVector(const Mat4 &mat, const Vec2 &vec, Vec2 *dst)
static Mat4 createScale(const Vec3 &scale)
Definition: CUMat4.h:503
Mat4 & operator+=(const Mat4 &mat)
Definition: CUMat4.h:1102
Mat4 & rotateZ(float angle)
Definition: CUMat4.h:1882
static const Mat4 ONE
Definition: CUMat4.h:112
static Mat4 createRotationY(float angle)
Definition: CUMat4.h:608
bool isExactly(const Mat4 &mat) const
Mat4 & translate(float tx, float ty, float tz)
Definition: CUMat4.h:1956
static Mat4 * subtract(const Mat4 &mat, float scalar, Mat4 *dst)
static Mat4 * rotateX(const Mat4 &mat, float angle, Mat4 *dst)
Definition: CUMat4.h:1631
Mat4 & rotateY(float angle)
Definition: CUMat4.h:1866
Mat4 & operator-=(const Mat4 &mat)
Definition: CUMat4.h:1113
static Mat4 createScale(float scale)
Definition: CUMat4.h:455
Mat4 & rotateX(float angle)
Definition: CUMat4.h:1850
Mat4 & negate()
Definition: CUMat4.h:1018
Mat4 & operator*=(float scalar)
Definition: CUMat4.h:1138
Mat4 & multiply(float scalar)
Definition: CUMat4.h:995
static Mat4 * rotate(const Mat4 &mat, const Quaternion &quat, Mat4 *dst)
Definition: CUMat4.h:1588
static Mat4 * scale(const Mat4 &mat, float value, Mat4 *dst)
Definition: CUMat4.h:1692
Vec3 getRightVector() const
bool isIdentity(float variance=0.0f) const
Mat4 & transpose()
Definition: CUMat4.h:1071
static Mat4 * translate(const Mat4 &mat, float tx, float ty, float tz, Mat4 *dst)
Definition: CUMat4.h:1772
Mat4 & rotate(const Vec3 &axis, float angle)
Definition: CUMat4.h:1834
static Mat4 * scale(const Mat4 &mat, float sx, float sy, float sz, Mat4 *dst)
Definition: CUMat4.h:1732
Mat4 getInverse() const
Definition: CUMat4.h:1056
const Mat4 operator*(const Mat4 &mat) const
Definition: CUMat4.h:1193
static Mat4 createOrthographic(float width, float height, float zNearPlane, float zFarPlane)
Definition: CUMat4.h:342
static Mat4 createTranslation(float tx, float ty, float tz)
Definition: CUMat4.h:685
static Mat4 * rotateZ(const Mat4 &mat, float angle, Mat4 *dst)
Definition: CUMat4.h:1673
Mat4 & subtract(const Mat4 &mat)
Definition: CUMat4.h:984
static bool decompose(const Mat4 &mat, Vec3 *scale, Quaternion *rot, Vec3 *trans)
Mat4 & multiply(const Mat4 &mat)
Definition: CUMat4.h:1009
const Mat4 operator-(const Mat4 &mat) const
Definition: CUMat4.h:1165
bool isInvertible(float variance=CU_MATH_EPSILON) const
Definition: CUMat4.h:1294
Definition: CUVec4.h:73
static Mat4 createPerspective(float fieldOfView, float aspectRatio, float zNearPlane, float zFarPlane)
Definition: CUMat4.h:290
const Mat4 operator+(const Mat4 &mat) const
Definition: CUMat4.h:1151
std::string toString(bool verbose=false) const
Mat4 & operator=(const float *array)
Definition: CUMat4.h:743
Mat4 & operator=(const Quaternion &quat)
Definition: CUMat4.h:754
Mat4 & add(const Mat4 &mat)
Definition: CUMat4.h:962
static Mat4 * rotateY(const Mat4 &mat, float angle, Mat4 *dst)
Definition: CUMat4.h:1652
Definition: CURect.h:45
bool equals(const Mat4 &mat, float variance=CU_MATH_EPSILON) const
static const Mat4 IDENTITY
Definition: CUMat4.h:114
static Mat4 * scale(const Mat4 &mat, const Vec3 &s, Mat4 *dst)
Definition: CUMat4.h:1711
static Mat4 * createOrthographic(float width, float height, float zNearPlane, float zFarPlane, Mat4 *dst)
Definition: CUMat4.h:375
const Mat4 operator*(float scalar) const
Definition: CUMat4.h:1207
static Mat4 createLookAt(float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ, float upX, float upY, float upZ)
Definition: CUMat4.h:243
Mat4 & subtract(float scalar)
Definition: CUMat4.h:973
int operator*(Font::Style value)
Definition: CUFont.h:1503
Mat4 getTranspose() const
Definition: CUMat4.h:1086
Mat4 & setIdentity()
Definition: CUVec3.h:61
Mat4 getNegation() const
Definition: CUMat4.h:1029
Mat4 & scale(float sx, float sy, float sz)
Definition: CUMat4.h:1926
static Mat4 createRotation(const Quaternion &quat)
Definition: CUMat4.h:525
Mat4 & translate(const Vec3 &t)
Definition: CUMat4.h:1940
static Mat4 * add(const Mat4 &mat, float scalar, Mat4 *dst)
const Mat4 operator-() const
Definition: CUMat4.h:1177
Mat4 & rotate(const Quaternion &q)
Definition: CUMat4.h:1817
Definition: CUAction.h:51
Vec3 getDownVector() const
Definition: CUQuaternion.h:97
Definition: CUMat4.h:92
static Mat4 createTranslation(const Vec3 &trans)
Definition: CUMat4.h:661
static Mat4 * translate(const Mat4 &mat, const Vec3 &t, Mat4 *dst)
Definition: CUMat4.h:1751
Vec3 getUpVector() const
static Mat4 createRotationZ(float angle)
Definition: CUMat4.h:636
static const Mat4 ZERO
Definition: CUMat4.h:110
static Mat4 createLookAt(const Vec3 &eye, const Vec3 &target, const Vec3 &up)
Definition: CUMat4.h:210
Quaternion getRotation() const
Vec3 getLeftVector() const
static Mat4 * rotate(const Mat4 &mat, const Vec3 &axis, float angle, Mat4 *dst)
Definition: CUMat4.h:1610
Mat4 & setZero()
bool operator==(const Mat4 &mat) const
Definition: CUMat4.h:1251
Mat4 & operator*=(const Mat4 &mat)
Definition: CUMat4.h:1127
Mat4 & invert()
Definition: CUMat4.h:1043
bool operator!=(const Mat4 &mat) const
Definition: CUMat4.h:1265