CUGL
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(32)) 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(const Quaternion& rotation) {
183  createRotation(rotation, this);
184  }
185 
189  ~Mat4() {}
190 
191 
192 #pragma mark -
193 #pragma mark Static Constructors
194 
203  static Mat4 createLookAt(const Vec3& eye, const Vec3& target, const Vec3& up) {
204  Mat4 result;
205  return *(createLookAt(eye,target,up,&result));
206  }
207 
208 
219  static Mat4* createLookAt(const Vec3& eye, const Vec3& target, const Vec3& up, Mat4* dst);
220 
236  static Mat4 createLookAt(float eyeX, float eyeY, float eyeZ,
237  float targetX, float targetY, float targetZ,
238  float upX, float upY, float upZ) {
239  Mat4 result;
240  return *(createLookAt(eyeX, eyeY, eyeZ,
241  targetX, targetY, targetZ,
242  upX, upY, upZ, &result));
243  }
244 
261  static Mat4* createLookAt(float eyeX, float eyeY, float eyeZ,
262  float targetX, float targetY, float targetZ,
263  float upX, float upY, float upZ, Mat4* dst);
264 
265 
283  static Mat4 createPerspective(float fieldOfView, float aspectRatio,
284  float zNearPlane, float zFarPlane) {
285  Mat4 result;
286  return *(createPerspective(fieldOfView, aspectRatio, zNearPlane, zFarPlane, &result));
287  }
288 
307  static Mat4* createPerspective(float fieldOfView, float aspectRatio,
308  float zNearPlane, float zFarPlane, Mat4* dst);
309 
335  static Mat4 createOrthographic(float width, float height,
336  float zNearPlane, float zFarPlane) {
337  Mat4 result;
338  return *(createOrthographic(width, height, zNearPlane, zFarPlane, &result));
339  }
340 
341 
368  static Mat4* createOrthographic(float width, float height,
369  float zNearPlane, float zFarPlane, Mat4* dst) {
370  float halfWidth = width / 2.0f;
371  float halfHeight = height / 2.0f;
372  return createOrthographicOffCenter(-halfWidth, halfWidth, -halfHeight, halfHeight,
373  zNearPlane, zFarPlane, dst);
374  }
375 
403  static Mat4 createOrthographicOffCenter(float left, float right, float bottom, float top,
404  float zNearPlane, float zFarPlane) {
405  Mat4 result;
406  return *(createOrthographicOffCenter(left, right, bottom, top, zNearPlane, zFarPlane, &result));
407  }
408 
409 
438  static Mat4* createOrthographicOffCenter(float left, float right, float bottom, float top,
439  float zNearPlane, float zFarPlane, Mat4* dst);
440 
448  static Mat4 createScale(float scale) {
449  Mat4 result;
450  return *(createScale(scale,&result));
451  }
452 
461  static Mat4* createScale(float scale, Mat4* dst);
462 
472  static Mat4 createScale(float sx, float sy, float sz) {
473  Mat4 result;
474  return *(createScale(sx,sy,sz,&result));
475  }
476 
487  static Mat4* createScale(float sx, float sy, float sz, Mat4* dst);
488 
496  static Mat4 createScale(const Vec3& scale) {
497  Mat4 result;
498  return *(createScale(scale,&result));
499  }
500 
509  static Mat4* createScale(const Vec3& scale, Mat4* dst);
510 
518  static Mat4 createRotation(const Quaternion& quat) {
519  Mat4 result;
520  return *(createRotation(quat,&result));
521  }
522 
531  static Mat4* createRotation(const Quaternion& quat, Mat4* dst);
532 
544  static Mat4 createRotation(const Vec3& axis, float angle) {
545  Mat4 result;
546  return *(createRotation(axis,angle,&result));
547  }
548 
561  static Mat4* createRotation(const Vec3& axis, float angle, Mat4* dst);
562 
573  static Mat4 createRotationX(float angle) {
574  Mat4 result;
575  return *(createRotationX(angle,&result));
576  }
577 
589  static Mat4* createRotationX(float angle, Mat4* dst);
590 
601  static Mat4 createRotationY(float angle) {
602  Mat4 result;
603  return *(createRotationY(angle,&result));
604  }
605 
617  static Mat4* createRotationY(float angle, Mat4* dst);
618 
629  static Mat4 createRotationZ(float angle) {
630  Mat4 result;
631  return *(createRotationZ(angle,&result));
632  }
633 
645  static Mat4* createRotationZ(float angle, Mat4* dst);
646 
654  static Mat4 createTranslation(const Vec3& trans) {
655  Mat4 result;
656  return *(createTranslation(trans,&result));
657  }
658 
667  static Mat4* createTranslation(const Vec3& trans, Mat4* dst);
668 
678  static Mat4 createTranslation(float tx, float ty, float tz) {
679  Mat4 result;
680  return *(createTranslation(tx,ty,tz,&result));
681  }
682 
693  static Mat4* createTranslation(float tx, float ty, float tz, Mat4* dst);
694 
695 
696 #pragma mark -
697 #pragma mark Setters
698 
705  Mat4& operator=(const Mat4& mat) {
706  return set(mat);
707  }
708 
724  Mat4& operator=(const float* array) {
725  return set(array);
726  }
727 
735  Mat4& operator=(const Quaternion& quat) {
736  return set(quat);
737  }
738 
761  Mat4& set(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24,
762  float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44);
763 
779  Mat4& set(const float* mat);
780 
788  Mat4& set(const Quaternion& quat);
789 
797  Mat4& set(const Mat4& mat);
798 
804  Mat4& setIdentity();
805 
811  Mat4& setZero();
812 
813 
814 #pragma mark -
815 #pragma mark Static Arithmetic
816 
826  static Mat4* add(const Mat4& mat, float scalar, Mat4* dst);
827 
837  static Mat4* add(const Mat4& m1, const Mat4& m2, Mat4* dst);
838 
848  static Mat4* subtract(const Mat4& mat, float scalar, Mat4* dst);
849 
859  static Mat4* subtract(const Mat4& m1, const Mat4& m2, Mat4* dst);
860 
870  static Mat4* multiply(const Mat4& mat, float scalar, Mat4* dst);
871 
884  static Mat4* multiply(const Mat4& m1, const Mat4& m2, Mat4* dst);
885 
894  static Mat4* negate(const Mat4& m1, Mat4* dst);
895 
907  static Mat4* invert(const Mat4& m1, Mat4* dst);
908 
921  static Mat4* transpose(const Mat4& m1, Mat4* dst);
922 
923 #pragma mark -
924 #pragma mark Arithmetic
925 
932  Mat4& add(float scalar) {
933  return *(add(*this,scalar,this));
934  }
935 
943  Mat4& add(const Mat4& mat) {
944  return *(add(*this,mat,this));
945  }
946 
954  Mat4& subtract(float scalar) {
955  return *(subtract(*this,scalar,this));
956  }
957 
965  Mat4& subtract(const Mat4& mat) {
966  return *(subtract(*this,mat,this));
967  }
968 
976  Mat4& multiply(float scalar) {
977  return *(multiply(*this,scalar,this));
978  }
979 
990  Mat4& multiply(const Mat4& mat) {
991  return *(multiply(*this,mat,this));
992  }
993 
1000  return *(negate(*this,this));
1001  }
1002 
1010  Mat4 getNegation() const {
1011  Mat4 result;
1012  negate(*this,&result);
1013  return result;
1014  }
1015 
1025  return *(invert(*this,this));
1026  }
1027 
1037  Mat4 getInverse() const {
1038  Mat4 result;
1039  invert(*this,&result);
1040  return result;
1041  }
1042 
1053  return *(transpose(*this,this));
1054  }
1055 
1067  Mat4 getTranspose() const {
1068  Mat4 result;
1069  transpose(*this,&result);
1070  return result;
1071  }
1072 
1073 
1074 #pragma mark -
1075 #pragma mark Operators
1076 
1083  Mat4& operator+=(const Mat4& mat) {
1084  return add(mat);
1085  }
1086 
1094  Mat4& operator-=(const Mat4& mat) {
1095  return subtract(mat);
1096  }
1097 
1108  Mat4& operator*=(const Mat4& mat) {
1109  return multiply(mat);
1110  }
1111 
1119  Mat4& operator*=(float scalar) {
1120  return multiply(scalar);
1121  }
1122 
1132  const Mat4 operator+(const Mat4& mat) const {
1133  Mat4 result(*this);
1134  return result.add(mat);
1135  }
1136 
1146  const Mat4 operator-(const Mat4& mat) const {
1147  Mat4 result(*this);
1148  return result.subtract(mat);
1149  }
1150 
1158  const Mat4 operator-() const {
1159  return getNegation();
1160  }
1161 
1174  const Mat4 operator*(const Mat4& mat) const {
1175  Mat4 result(*this);
1176  return result.multiply(mat);
1177  }
1178 
1188  const Mat4 operator*(float scalar) const {
1189  Mat4 result(*this);
1190  return result.multiply(scalar);
1191  }
1192 
1193 
1194 #pragma mark -
1195 #pragma mark Comparisons
1196 
1207  bool isExactly(const Mat4& mat) const;
1208 
1219  bool equals(const Mat4& mat, float variance=CU_MATH_EPSILON) const;
1220 
1232  bool operator==(const Mat4& mat) const {
1233  return isExactly(mat);
1234  }
1235 
1246  bool operator!=(const Mat4& mat) const {
1247  return !isExactly(mat);
1248  }
1249 
1250 
1251 #pragma mark -
1252 #pragma mark Matrix Attributes
1253 
1264  bool isIdentity(float variance=0.0f) const;
1265 
1275  bool isInvertible(float variance=CU_MATH_EPSILON) const {
1276  return fabsf(getDeterminant()) > variance;
1277  }
1278 
1288  bool isOrthogonal(float variance=CU_MATH_EPSILON) const;
1289 
1295  float getDeterminant() const;
1296 
1311  Vec3 getScale() const;
1312 
1321  Quaternion getRotation() const;
1322 
1332  Vec3 getTranslation() const;
1333 
1339  Vec3 getUpVector() const;
1340 
1346  Vec3 getDownVector() const;
1352  Vec3 getLeftVector() const;
1353 
1359  Vec3 getRightVector() const;
1360 
1366  Vec3 getForwardVector() const;
1367 
1373  Vec3 getBackVector() const;
1374 
1375 
1376 #pragma mark -
1377 #pragma mark Static Vector Operations
1378 
1390  static Vec2* transform(const Mat4& mat, const Vec2& point, Vec2* dst);
1391 
1404  static Rect* transform(const Mat4& mat, const Rect& rect, Rect* dst);
1405 
1418  static Vec2* transformVector(const Mat4& mat, const Vec2& vec, Vec2* dst);
1419 
1432  static Vec3* transform(const Mat4& mat, const Vec3& point, Vec3* dst);
1433 
1446  static Vec3* transformVector(const Mat4& mat, const Vec3& vec, Vec3* dst);
1447 
1460  static Vec4* transform(const Mat4& mat, const Vec4& vec, Vec4* dst);
1461 
1462 
1463 #pragma mark -
1464 #pragma mark Vector Operations
1465 
1478  Vec2 transform(const Vec2& point) const;
1479 
1493  Rect transform(const Rect& rect) const;
1494 
1508  Vec2 transformVector(const Vec2& vec) const;
1509 
1523  Vec3 transform(const Vec3& point) const;
1524 
1538  Vec3 transformVector(const Vec3& vec) const;
1539 
1553  Vec4 transform(const Vec4& vec) const;
1554 
1555 #pragma mark -
1556 #pragma mark Static Matrix Transforms
1557 
1569  static Mat4* rotate(const Mat4& mat, const Quaternion& quat, Mat4* dst) {
1570  Mat4 result;
1571  createRotation(quat, &result);
1572  multiply(mat, result, dst);
1573  return dst;
1574  }
1575 
1591  static Mat4* rotate(const Mat4& mat, const Vec3& axis, float angle, Mat4* dst) {
1592  Mat4 result;
1593  createRotation(axis, angle, &result);
1594  multiply(mat, result, dst);
1595  return dst;
1596  }
1597 
1612  static Mat4* rotateX(const Mat4& mat, float angle, Mat4* dst) {
1613  Mat4 result;
1614  createRotationX(angle, &result);
1615  multiply(mat, result, dst);
1616  return dst;
1617  }
1618 
1633  static Mat4* rotateY(const Mat4& mat, float angle, Mat4* dst) {
1634  Mat4 result;
1635  createRotationY(angle, &result);
1636  multiply(mat, result, dst);
1637  return dst;
1638  }
1639 
1654  static Mat4* rotateZ(const Mat4& mat, float angle, Mat4* dst) {
1655  Mat4 result;
1656  createRotationZ(angle, &result);
1657  multiply(mat, result, dst);
1658  return dst;
1659  }
1660 
1673  static Mat4* scale(const Mat4& mat, float value, Mat4* dst) {
1674  Mat4 result;
1675  createScale(value, &result);
1676  multiply(mat, result, dst);
1677  return dst;
1678  }
1679 
1692  static Mat4* scale(const Mat4& mat, const Vec3& s, Mat4* dst) {
1693  Mat4 result;
1694  createScale(s, &result);
1695  multiply(mat, result, dst);
1696  return dst;
1697  }
1698 
1713  static Mat4* scale(const Mat4& mat, float sx, float sy, float sz, Mat4* dst) {
1714  Mat4 result;
1715  createScale(sx,sy,sz, &result);
1716  multiply(mat, result, dst);
1717  return dst;
1718  }
1719 
1732  static Mat4* translate(const Mat4& mat, const Vec3& t, Mat4* dst) {
1733  Mat4 result;
1734  createTranslation(t, &result);
1735  multiply(mat, result, dst);
1736  return dst;
1737  }
1738 
1753  static Mat4* translate(const Mat4& mat, float tx, float ty, float tz, Mat4* dst) {
1754  Mat4 result;
1755  createTranslation(tx,ty,tz, &result);
1756  multiply(mat, result, dst);
1757  return dst;
1758  }
1759 
1783  static bool decompose(const Mat4& mat, Vec3* scale, Quaternion* rot, Vec3* trans);
1784 
1785 
1786 #pragma mark -
1787 #pragma mark Matrix Transforms
1788 
1798  Mat4& rotate(const Quaternion& q) {
1799  return *(rotate(*this,q,this));
1800  }
1801 
1815  Mat4& rotate(const Vec3& axis, float angle) {
1816  return *(rotate(*this,axis,angle,this));
1817  }
1818 
1831  Mat4& rotateX(float angle) {
1832  return *(rotateX(*this,angle,this));
1833  }
1834 
1847  Mat4& rotateY(float angle) {
1848  return *(rotateY(*this,angle,this));
1849  }
1850 
1863  Mat4& rotateZ(float angle) {
1864  return *(rotateZ(*this,angle,this));
1865  }
1866 
1877  Mat4& scale(float value) {
1878  return *(scale(*this,value,this));
1879  }
1880 
1891  Mat4& scale(const Vec3& s) {
1892  return *(scale(*this,s,this));
1893  }
1894 
1907  Mat4& scale(float sx, float sy, float sz) {
1908  return *(scale(*this,sx,sy,sz,this));
1909  }
1910 
1921  Mat4& translate(const Vec3& t) {
1922  return *(translate(*this,t,this));
1923  }
1924 
1937  Mat4& translate(float tx, float ty, float tz) {
1938  return *(translate(*this,tx,ty,tz,this));
1939  }
1940 
1941 
1942 #pragma mark -
1943 #pragma mark Conversion Methods
1944 
1954  std::string toString(bool verbose = false) const;
1955 
1957  operator std::string() const { return toString(); }
1958 
1967  operator Affine2() const;
1968 
1976  explicit Mat4(const Affine2& aff);
1977 
1987  Mat4& operator= (const Affine2& aff);
1988 
1998  Mat4& set(const Affine2& aff);
1999 };
2000 
2001 #pragma mark -
2002 #pragma mark Vector Operations
2003 // To avoid confusion, we NEVER support vector on the right ops.
2004 
2016 inline Vec2& operator*=(Vec2& v, const Mat4& m) {
2017  return *(Mat4::transform(m,v,&v));
2018 }
2019 
2031 inline const Vec2 operator*(const Vec2& v, const Mat4& m) {
2032  return m.transform(v);
2033 }
2034 
2046 inline Vec3& operator*=(Vec3& v, const Mat4& m) {
2047  return *(Mat4::transform(m,v,&v));
2048 }
2049 
2061 inline const Vec3 operator*(const Vec3& v, const Mat4& m) {
2062  return m.transform(v);
2063 }
2064 
2076 inline Vec4& operator*=(Vec4& v, const Mat4& m) {
2077  return *(Mat4::transform(m,v,&v));
2078 }
2079 
2091 inline const Vec4 operator*(const Vec4& v, const Mat4& m) {
2092  return m.transform(v);
2093 }
2094 
2103 inline const Mat4 operator*(float scalar, const Mat4& m) {
2104  Mat4 result(m);
2105  return result.multiply(scalar);
2106 }
2107 
2108 }
2109 
2110 #endif /* __CU_MAT4_H__ */
static Mat4 createRotationX(float angle)
Definition: CUMat4.h:573
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:705
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:544
Vec2 & operator*=(Vec2 &v, const Affine2 &m)
Definition: CUAffine2.h:1145
Definition: CUVec2.h:61
Mat4(const Quaternion &rotation)
Definition: CUMat4.h:182
Definition: CUAffine2.h:63
float getDeterminant() const
static Mat4 createScale(float sx, float sy, float sz)
Definition: CUMat4.h:472
static Mat4 createOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane)
Definition: CUMat4.h:403
Mat4 & scale(const Vec3 &s)
Definition: CUMat4.h:1891
Mat4 & scale(float value)
Definition: CUMat4.h:1877
~Mat4()
Definition: CUMat4.h:189
Mat4 & add(float scalar)
Definition: CUMat4.h:932
static Vec2 * transformVector(const Mat4 &mat, const Vec2 &vec, Vec2 *dst)
static Mat4 createScale(const Vec3 &scale)
Definition: CUMat4.h:496
Mat4 & operator+=(const Mat4 &mat)
Definition: CUMat4.h:1083
Mat4 & rotateZ(float angle)
Definition: CUMat4.h:1863
static const Mat4 ONE
Definition: CUMat4.h:112
static Mat4 createRotationY(float angle)
Definition: CUMat4.h:601
bool isExactly(const Mat4 &mat) const
Mat4 & translate(float tx, float ty, float tz)
Definition: CUMat4.h:1937
static Mat4 * subtract(const Mat4 &mat, float scalar, Mat4 *dst)
static Mat4 * rotateX(const Mat4 &mat, float angle, Mat4 *dst)
Definition: CUMat4.h:1612
Mat4 & rotateY(float angle)
Definition: CUMat4.h:1847
Mat4 & operator-=(const Mat4 &mat)
Definition: CUMat4.h:1094
static Mat4 createScale(float scale)
Definition: CUMat4.h:448
Mat4 & rotateX(float angle)
Definition: CUMat4.h:1831
Mat4 & negate()
Definition: CUMat4.h:999
Mat4 & operator*=(float scalar)
Definition: CUMat4.h:1119
Mat4 & multiply(float scalar)
Definition: CUMat4.h:976
static Mat4 * rotate(const Mat4 &mat, const Quaternion &quat, Mat4 *dst)
Definition: CUMat4.h:1569
static Mat4 * scale(const Mat4 &mat, float value, Mat4 *dst)
Definition: CUMat4.h:1673
Vec3 getRightVector() const
bool isIdentity(float variance=0.0f) const
Mat4 & transpose()
Definition: CUMat4.h:1052
static Mat4 * translate(const Mat4 &mat, float tx, float ty, float tz, Mat4 *dst)
Definition: CUMat4.h:1753
Mat4 & rotate(const Vec3 &axis, float angle)
Definition: CUMat4.h:1815
static Mat4 * scale(const Mat4 &mat, float sx, float sy, float sz, Mat4 *dst)
Definition: CUMat4.h:1713
Mat4 getInverse() const
Definition: CUMat4.h:1037
const Mat4 operator*(const Mat4 &mat) const
Definition: CUMat4.h:1174
static Mat4 createOrthographic(float width, float height, float zNearPlane, float zFarPlane)
Definition: CUMat4.h:335
static Mat4 createTranslation(float tx, float ty, float tz)
Definition: CUMat4.h:678
static Mat4 * rotateZ(const Mat4 &mat, float angle, Mat4 *dst)
Definition: CUMat4.h:1654
Mat4 & subtract(const Mat4 &mat)
Definition: CUMat4.h:965
static bool decompose(const Mat4 &mat, Vec3 *scale, Quaternion *rot, Vec3 *trans)
Mat4 & multiply(const Mat4 &mat)
Definition: CUMat4.h:990
const Mat4 operator-(const Mat4 &mat) const
Definition: CUMat4.h:1146
bool isInvertible(float variance=CU_MATH_EPSILON) const
Definition: CUMat4.h:1275
Definition: CUVec4.h:73
static Mat4 createPerspective(float fieldOfView, float aspectRatio, float zNearPlane, float zFarPlane)
Definition: CUMat4.h:283
const Mat4 operator+(const Mat4 &mat) const
Definition: CUMat4.h:1132
std::string toString(bool verbose=false) const
Mat4 & operator=(const float *array)
Definition: CUMat4.h:724
Mat4 & operator=(const Quaternion &quat)
Definition: CUMat4.h:735
Mat4 & add(const Mat4 &mat)
Definition: CUMat4.h:943
static Mat4 * rotateY(const Mat4 &mat, float angle, Mat4 *dst)
Definition: CUMat4.h:1633
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:1692
static Mat4 * createOrthographic(float width, float height, float zNearPlane, float zFarPlane, Mat4 *dst)
Definition: CUMat4.h:368
const Mat4 operator*(float scalar) const
Definition: CUMat4.h:1188
static Mat4 createLookAt(float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ, float upX, float upY, float upZ)
Definition: CUMat4.h:236
Mat4 & subtract(float scalar)
Definition: CUMat4.h:954
int operator*(Font::Style value)
Definition: CUFont.h:1503
Mat4 getTranspose() const
Definition: CUMat4.h:1067
Mat4 & setIdentity()
Definition: CUVec3.h:61
Mat4 getNegation() const
Definition: CUMat4.h:1010
Mat4 & scale(float sx, float sy, float sz)
Definition: CUMat4.h:1907
static Mat4 createRotation(const Quaternion &quat)
Definition: CUMat4.h:518
Mat4 & translate(const Vec3 &t)
Definition: CUMat4.h:1921
static Mat4 * add(const Mat4 &mat, float scalar, Mat4 *dst)
const Mat4 operator-() const
Definition: CUMat4.h:1158
Mat4 & rotate(const Quaternion &q)
Definition: CUMat4.h:1798
Definition: CUAnimationNode.h:52
Vec3 getDownVector() const
Definition: CUQuaternion.h:97
Definition: CUMat4.h:92
static Mat4 createTranslation(const Vec3 &trans)
Definition: CUMat4.h:654
static Mat4 * translate(const Mat4 &mat, const Vec3 &t, Mat4 *dst)
Definition: CUMat4.h:1732
Vec3 getUpVector() const
static Mat4 createRotationZ(float angle)
Definition: CUMat4.h:629
static const Mat4 ZERO
Definition: CUMat4.h:110
static Mat4 createLookAt(const Vec3 &eye, const Vec3 &target, const Vec3 &up)
Definition: CUMat4.h:203
Quaternion getRotation() const
Vec3 getLeftVector() const
static Mat4 * rotate(const Mat4 &mat, const Vec3 &axis, float angle, Mat4 *dst)
Definition: CUMat4.h:1591
Mat4 & setZero()
bool operator==(const Mat4 &mat) const
Definition: CUMat4.h:1232
Mat4 & operator*=(const Mat4 &mat)
Definition: CUMat4.h:1108
Mat4 & invert()
Definition: CUMat4.h:1024
bool operator!=(const Mat4 &mat) const
Definition: CUMat4.h:1246