CUGL 1.2
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 //
9 // This version (2018) no longer supports manual vectorization for AVX, Neon.
10 // Because these matrices are small, the compiler seems to be able to optimize
11 // the naive code better. Naive code with -O3 outperforms the manual vectorization
12 // by almost a full order of magnitude.
13 //
14 // Because math objects are intended to be on the stack, we do not provide
15 // any shared pointer support in this class.
16 //
17 // This module is based on an original file from GamePlay3D: http://gameplay3d.org.
18 // It has been modified to support the CUGL framework.
19 //
20 // CUGL MIT License:
21 // This software is provided 'as-is', without any express or implied
22 // warranty. In no event will the authors be held liable for any damages
23 // arising from the use of this software.
24 //
25 // Permission is granted to anyone to use this software for any purpose,
26 // including commercial applications, and to alter it and redistribute it
27 // freely, subject to the following restrictions:
28 //
29 // 1. The origin of this software must not be misrepresented; you must not
30 // claim that you wrote the original software. If you use this software
31 // in a product, an acknowledgment in the product documentation would be
32 // appreciated but is not required.
33 //
34 // 2. Altered source versions must be plainly marked as such, and must not
35 // be misrepresented as being the original software.
36 //
37 // 3. This notice may not be removed or altered from any source distribution.
38 //
39 // Author: Walker White
40 // Version: 4/3/18
41 
42 #ifndef __CU_MAT4_H__
43 #define __CU_MAT4_H__
44 
45 #include <math.h>
46 #include <assert.h>
47 #include "CUMathBase.h"
48 #include "CUVec2.h"
49 #include "CUVec3.h"
50 #include "CUVec4.h"
51 #include "CURect.h"
52 
53 namespace cugl {
54 
55 // Forward references
56 class Quaternion;
57 class Affine2;
58 
83 class Mat4 {
84 #pragma mark Values
85 public:
86 #if defined CU_MATH_VECTOR_SSE
87  __attribute__((__aligned__(16))) union {
88  __m128 col[4];
89  float m[16];
90  };
91 #elif defined CU_MATH_VECTOR_NEON64
92  __attribute__((__aligned__(16))) union {
93  float32x4_t col[4];
94  float m[16];
95  };
96 #else
97  float m[16];
98 #endif
99 
101  static const Mat4 ZERO;
103  static const Mat4 ONE;
105  static const Mat4 IDENTITY;
106 
107 
108 #pragma mark -
109 #pragma mark Constructors
110 public:
119  Mat4();
120 
141  Mat4(float m11, float m12, float m13, float m14,
142  float m21, float m22, float m23, float m24,
143  float m31, float m32, float m33, float m34,
144  float m41, float m42, float m43, float m44);
145 
159  Mat4(const float* mat);
160 
166  Mat4(const Mat4& copy);
167 
173  Mat4(Mat4&& copy);
174 
180  Mat4(const Quaternion& rotation) {
181  createRotation(rotation, this);
182  }
183 
187  ~Mat4() {}
188 
189 
190 #pragma mark -
191 #pragma mark Static Constructors
192 
201  static Mat4 createLookAt(const Vec3& eye, const Vec3& target, const Vec3& up) {
202  Mat4 result;
203  return *(createLookAt(eye,target,up,&result));
204  }
205 
206 
217  static Mat4* createLookAt(const Vec3& eye, const Vec3& target, const Vec3& up, Mat4* dst);
218 
234  static Mat4 createLookAt(float eyeX, float eyeY, float eyeZ,
235  float targetX, float targetY, float targetZ,
236  float upX, float upY, float upZ) {
237  Mat4 result;
238  return *(createLookAt(eyeX, eyeY, eyeZ,
239  targetX, targetY, targetZ,
240  upX, upY, upZ, &result));
241  }
242 
259  static Mat4* createLookAt(float eyeX, float eyeY, float eyeZ,
260  float targetX, float targetY, float targetZ,
261  float upX, float upY, float upZ, Mat4* dst);
262 
263 
281  static Mat4 createPerspective(float fieldOfView, float aspectRatio,
282  float zNearPlane, float zFarPlane) {
283  Mat4 result;
284  return *(createPerspective(fieldOfView, aspectRatio, zNearPlane, zFarPlane, &result));
285  }
286 
305  static Mat4* createPerspective(float fieldOfView, float aspectRatio,
306  float zNearPlane, float zFarPlane, Mat4* dst);
307 
333  static Mat4 createOrthographic(float width, float height,
334  float zNearPlane, float zFarPlane) {
335  Mat4 result;
336  return *(createOrthographic(width, height, zNearPlane, zFarPlane, &result));
337  }
338 
339 
366  static Mat4* createOrthographic(float width, float height,
367  float zNearPlane, float zFarPlane, Mat4* dst) {
368  float halfWidth = width / 2.0f;
369  float halfHeight = height / 2.0f;
370  return createOrthographicOffCenter(-halfWidth, halfWidth, -halfHeight, halfHeight,
371  zNearPlane, zFarPlane, dst);
372  }
373 
401  static Mat4 createOrthographicOffCenter(float left, float right, float bottom, float top,
402  float zNearPlane, float zFarPlane) {
403  Mat4 result;
404  return *(createOrthographicOffCenter(left, right, bottom, top, zNearPlane, zFarPlane, &result));
405  }
406 
407 
436  static Mat4* createOrthographicOffCenter(float left, float right, float bottom, float top,
437  float zNearPlane, float zFarPlane, Mat4* dst);
438 
446  static Mat4 createScale(float scale) {
447  Mat4 result;
448  return *(createScale(scale,&result));
449  }
450 
459  static Mat4* createScale(float scale, Mat4* dst);
460 
470  static Mat4 createScale(float sx, float sy, float sz) {
471  Mat4 result;
472  return *(createScale(sx,sy,sz,&result));
473  }
474 
485  static Mat4* createScale(float sx, float sy, float sz, Mat4* dst);
486 
494  static Mat4 createScale(const Vec3& scale) {
495  Mat4 result;
496  return *(createScale(scale,&result));
497  }
498 
507  static Mat4* createScale(const Vec3& scale, Mat4* dst);
508 
516  static Mat4 createRotation(const Quaternion& quat) {
517  Mat4 result;
518  return *(createRotation(quat,&result));
519  }
520 
529  static Mat4* createRotation(const Quaternion& quat, Mat4* dst);
530 
542  static Mat4 createRotation(const Vec3& axis, float angle) {
543  Mat4 result;
544  return *(createRotation(axis,angle,&result));
545  }
546 
559  static Mat4* createRotation(const Vec3& axis, float angle, Mat4* dst);
560 
571  static Mat4 createRotationX(float angle) {
572  Mat4 result;
573  return *(createRotationX(angle,&result));
574  }
575 
587  static Mat4* createRotationX(float angle, Mat4* dst);
588 
599  static Mat4 createRotationY(float angle) {
600  Mat4 result;
601  return *(createRotationY(angle,&result));
602  }
603 
615  static Mat4* createRotationY(float angle, Mat4* dst);
616 
627  static Mat4 createRotationZ(float angle) {
628  Mat4 result;
629  return *(createRotationZ(angle,&result));
630  }
631 
643  static Mat4* createRotationZ(float angle, Mat4* dst);
644 
652  static Mat4 createTranslation(const Vec3& trans) {
653  Mat4 result;
654  return *(createTranslation(trans,&result));
655  }
656 
665  static Mat4* createTranslation(const Vec3& trans, Mat4* dst);
666 
676  static Mat4 createTranslation(float tx, float ty, float tz) {
677  Mat4 result;
678  return *(createTranslation(tx,ty,tz,&result));
679  }
680 
691  static Mat4* createTranslation(float tx, float ty, float tz, Mat4* dst);
692 
693 
694 #pragma mark -
695 #pragma mark Setters
696 
703  Mat4& operator=(const Mat4& mat) {
704  return set(mat);
705  }
706 
714  Mat4& operator=(Mat4&& mat) {
715  memcpy(this->m, mat.m, sizeof(float)*16);
716  return *this;
717  }
718 
734  Mat4& operator=(const float* array) {
735  return set(array);
736  }
737 
745  Mat4& operator=(const Quaternion& quat) {
746  return set(quat);
747  }
748 
771  Mat4& set(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24,
772  float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44);
773 
789  Mat4& set(const float* mat);
790 
798  Mat4& set(const Quaternion& quat);
799 
807  Mat4& set(const Mat4& mat);
808 
814  Mat4& setIdentity();
815 
821  Mat4& setZero();
822 
823 
824 #pragma mark -
825 #pragma mark Static Arithmetic
826 
836  static Mat4* add(const Mat4& mat, float scalar, Mat4* dst);
837 
847  static Mat4* add(const Mat4& m1, const Mat4& m2, Mat4* dst);
848 
858  static Mat4* subtract(const Mat4& mat, float scalar, Mat4* dst);
859 
869  static Mat4* subtract(const Mat4& m1, const Mat4& m2, Mat4* dst);
870 
880  static Mat4* multiply(const Mat4& mat, float scalar, Mat4* dst);
881 
894  static Mat4* multiply(const Mat4& m1, const Mat4& m2, Mat4* dst);
895 
904  static Mat4* negate(const Mat4& m1, Mat4* dst);
905 
917  static Mat4* invert(const Mat4& m1, Mat4* dst);
918 
931  static Mat4* transpose(const Mat4& m1, Mat4* dst);
932 
933 #pragma mark -
934 #pragma mark Arithmetic
935 
942  Mat4& add(float scalar) {
943  return *(add(*this,scalar,this));
944  }
945 
953  Mat4& add(const Mat4& mat) {
954  return *(add(*this,mat,this));
955  }
956 
964  Mat4& subtract(float scalar) {
965  return *(subtract(*this,scalar,this));
966  }
967 
975  Mat4& subtract(const Mat4& mat) {
976  return *(subtract(*this,mat,this));
977  }
978 
986  Mat4& multiply(float scalar) {
987  return *(multiply(*this,scalar,this));
988  }
989 
1000  Mat4& multiply(const Mat4& mat) {
1001  return *(multiply(*this,mat,this));
1002  }
1003 
1010  return *(negate(*this,this));
1011  }
1012 
1020  Mat4 getNegation() const {
1021  Mat4 result;
1022  negate(*this,&result);
1023  return result;
1024  }
1025 
1035  return *(invert(*this,this));
1036  }
1037 
1047  Mat4 getInverse() const {
1048  Mat4 result;
1049  invert(*this,&result);
1050  return result;
1051  }
1052 
1063  return *(transpose(*this,this));
1064  }
1065 
1077  Mat4 getTranspose() const {
1078  Mat4 result;
1079  transpose(*this,&result);
1080  return result;
1081  }
1082 
1083 
1084 #pragma mark -
1085 #pragma mark Operators
1086 
1093  Mat4& operator+=(const Mat4& mat) {
1094  return add(mat);
1095  }
1096 
1104  Mat4& operator-=(const Mat4& mat) {
1105  return subtract(mat);
1106  }
1107 
1118  Mat4& operator*=(const Mat4& mat) {
1119  return multiply(mat);
1120  }
1121 
1129  Mat4& operator*=(float scalar) {
1130  return multiply(scalar);
1131  }
1132 
1142  const Mat4 operator+(const Mat4& mat) const {
1143  Mat4 result(*this);
1144  return result.add(mat);
1145  }
1146 
1156  const Mat4 operator-(const Mat4& mat) const {
1157  Mat4 result(*this);
1158  return result.subtract(mat);
1159  }
1160 
1168  const Mat4 operator-() const {
1169  return getNegation();
1170  }
1171 
1184  const Mat4 operator*(const Mat4& mat) const {
1185  Mat4 result(*this);
1186  return result.multiply(mat);
1187  }
1188 
1198  const Mat4 operator*(float scalar) const {
1199  Mat4 result(*this);
1200  return result.multiply(scalar);
1201  }
1202 
1203 
1204 #pragma mark -
1205 #pragma mark Comparisons
1206 
1217  bool isExactly(const Mat4& mat) const;
1218 
1229  bool equals(const Mat4& mat, float variance=CU_MATH_EPSILON) const;
1230 
1242  bool operator==(const Mat4& mat) const {
1243  return isExactly(mat);
1244  }
1245 
1256  bool operator!=(const Mat4& mat) const {
1257  return !isExactly(mat);
1258  }
1259 
1260 
1261 #pragma mark -
1262 #pragma mark Matrix Attributes
1263 
1274  bool isIdentity(float variance=CU_MATH_EPSILON) const;
1275 
1285  bool isInvertible(float variance=CU_MATH_EPSILON) const {
1286  return fabsf(getDeterminant()) > variance;
1287  }
1288 
1298  bool isOrthogonal(float variance=CU_MATH_EPSILON) const;
1299 
1305  float getDeterminant() const;
1306 
1321  Vec3 getScale() const;
1322 
1331  Quaternion getRotation() const;
1332 
1342  Vec3 getTranslation() const;
1343 
1349  Vec3 getUpVector() const;
1350 
1356  Vec3 getDownVector() const;
1362  Vec3 getLeftVector() const;
1363 
1369  Vec3 getRightVector() const;
1370 
1376  Vec3 getForwardVector() const;
1377 
1383  Vec3 getBackVector() const;
1384 
1385 
1386 #pragma mark -
1387 #pragma mark Static Vector Operations
1388 
1400  static Vec2* transform(const Mat4& mat, const Vec2& point, Vec2* dst);
1401 
1414  static Rect* transform(const Mat4& mat, const Rect& rect, Rect* dst);
1415 
1428  static Vec2* transformVector(const Mat4& mat, const Vec2& vec, Vec2* dst);
1429 
1442  static Vec3* transform(const Mat4& mat, const Vec3& point, Vec3* dst);
1443 
1456  static Vec3* transformVector(const Mat4& mat, const Vec3& vec, Vec3* dst);
1457 
1470  static Vec4* transform(const Mat4& mat, const Vec4& vec, Vec4* dst);
1471 
1484  static float* transform(const Mat4& mat, float const* input, float* output, size_t size);
1485 
1486 
1487 #pragma mark -
1488 #pragma mark Vector Operations
1489 
1502  Vec2 transform(const Vec2& point) const;
1503 
1517  Rect transform(const Rect& rect) const;
1518 
1532  Vec2 transformVector(const Vec2& vec) const;
1533 
1547  Vec3 transform(const Vec3& point) const;
1548 
1562  Vec3 transformVector(const Vec3& vec) const;
1563 
1577  Vec4 transform(const Vec4& vec) const;
1578 
1579 #pragma mark -
1580 #pragma mark Static Matrix Transforms
1581 
1593  static Mat4* rotate(const Mat4& mat, const Quaternion& quat, Mat4* dst) {
1594  Mat4 result;
1595  createRotation(quat, &result);
1596  multiply(mat, result, dst);
1597  return dst;
1598  }
1599 
1615  static Mat4* rotate(const Mat4& mat, const Vec3& axis, float angle, Mat4* dst) {
1616  Mat4 result;
1617  createRotation(axis, angle, &result);
1618  multiply(mat, result, dst);
1619  return dst;
1620  }
1621 
1636  static Mat4* rotateX(const Mat4& mat, float angle, Mat4* dst) {
1637  Mat4 result;
1638  createRotationX(angle, &result);
1639  multiply(mat, result, dst);
1640  return dst;
1641  }
1642 
1657  static Mat4* rotateY(const Mat4& mat, float angle, Mat4* dst) {
1658  Mat4 result;
1659  createRotationY(angle, &result);
1660  multiply(mat, result, dst);
1661  return dst;
1662  }
1663 
1678  static Mat4* rotateZ(const Mat4& mat, float angle, Mat4* dst) {
1679  Mat4 result;
1680  createRotationZ(angle, &result);
1681  multiply(mat, result, dst);
1682  return dst;
1683  }
1684 
1697  static Mat4* scale(const Mat4& mat, float value, Mat4* dst) {
1698  Mat4 result;
1699  createScale(value, &result);
1700  multiply(mat, result, dst);
1701  return dst;
1702  }
1703 
1716  static Mat4* scale(const Mat4& mat, const Vec3& s, Mat4* dst) {
1717  Mat4 result;
1718  createScale(s, &result);
1719  multiply(mat, result, dst);
1720  return dst;
1721  }
1722 
1737  static Mat4* scale(const Mat4& mat, float sx, float sy, float sz, Mat4* dst) {
1738  Mat4 result;
1739  createScale(sx,sy,sz, &result);
1740  multiply(mat, result, dst);
1741  return dst;
1742  }
1743 
1756  static Mat4* translate(const Mat4& mat, const Vec3& t, Mat4* dst) {
1757  Mat4 result;
1758  createTranslation(t, &result);
1759  multiply(mat, result, dst);
1760  return dst;
1761  }
1762 
1777  static Mat4* translate(const Mat4& mat, float tx, float ty, float tz, Mat4* dst) {
1778  Mat4 result;
1779  createTranslation(tx,ty,tz, &result);
1780  multiply(mat, result, dst);
1781  return dst;
1782  }
1783 
1807  static bool decompose(const Mat4& mat, Vec3* scale, Quaternion* rot, Vec3* trans);
1808 
1809 
1810 #pragma mark -
1811 #pragma mark Matrix Transforms
1812 
1822  Mat4& rotate(const Quaternion& q) {
1823  return *(rotate(*this,q,this));
1824  }
1825 
1839  Mat4& rotate(const Vec3& axis, float angle) {
1840  return *(rotate(*this,axis,angle,this));
1841  }
1842 
1855  Mat4& rotateX(float angle) {
1856  return *(rotateX(*this,angle,this));
1857  }
1858 
1871  Mat4& rotateY(float angle) {
1872  return *(rotateY(*this,angle,this));
1873  }
1874 
1887  Mat4& rotateZ(float angle) {
1888  return *(rotateZ(*this,angle,this));
1889  }
1890 
1901  Mat4& scale(float value) {
1902  return *(scale(*this,value,this));
1903  }
1904 
1915  Mat4& scale(const Vec3& s) {
1916  return *(scale(*this,s,this));
1917  }
1918 
1931  Mat4& scale(float sx, float sy, float sz) {
1932  return *(scale(*this,sx,sy,sz,this));
1933  }
1934 
1945  Mat4& translate(const Vec3& t) {
1946  return *(translate(*this,t,this));
1947  }
1948 
1961  Mat4& translate(float tx, float ty, float tz) {
1962  return *(translate(*this,tx,ty,tz,this));
1963  }
1964 
1965 
1966 #pragma mark -
1967 #pragma mark Conversion Methods
1968 
1978  std::string toString(bool verbose = false) const;
1979 
1981  operator std::string() const { return toString(); }
1982 
1991  operator Affine2() const;
1992 
2000  explicit Mat4(const Affine2& aff);
2001 
2011  Mat4& operator= (const Affine2& aff);
2012 
2022  Mat4& set(const Affine2& aff);
2023 };
2024 
2025 #pragma mark -
2026 #pragma mark Vector Operations
2027 // To avoid confusion, we NEVER support vector on the right ops.
2028 
2040 inline Vec2& operator*=(Vec2& v, const Mat4& m) {
2041  return *(Mat4::transform(m,v,&v));
2042 }
2043 
2055 inline const Vec2 operator*(const Vec2& v, const Mat4& m) {
2056  return m.transform(v);
2057 }
2058 
2070 inline Vec3& operator*=(Vec3& v, const Mat4& m) {
2071  return *(Mat4::transform(m,v,&v));
2072 }
2073 
2085 inline const Vec3 operator*(const Vec3& v, const Mat4& m) {
2086  return m.transform(v);
2087 }
2088 
2100 inline Vec4& operator*=(Vec4& v, const Mat4& m) {
2101  return *(Mat4::transform(m,v,&v));
2102 }
2103 
2115 inline const Vec4 operator*(const Vec4& v, const Mat4& m) {
2116  return m.transform(v);
2117 }
2118 
2127 inline const Mat4 operator*(float scalar, const Mat4& m) {
2128  Mat4 result(m);
2129  return result.multiply(scalar);
2130 }
2131 
2132 }
2133 
2134 #endif /* __CU_MAT4_H__ */
static Mat4 createRotationX(float angle)
Definition: CUMat4.h:571
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:703
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:542
Definition: CUVec2.h:61
Mat4(const Quaternion &rotation)
Definition: CUMat4.h:180
bool isIdentity(float variance=CU_MATH_EPSILON) const
Definition: CUAffine2.h:63
float getDeterminant() const
Mat4 & operator=(Mat4 &&mat)
Definition: CUMat4.h:714
static Mat4 createScale(float sx, float sy, float sz)
Definition: CUMat4.h:470
static Mat4 createOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane)
Definition: CUMat4.h:401
Mat4 & scale(const Vec3 &s)
Definition: CUMat4.h:1915
Mat4 & scale(float value)
Definition: CUMat4.h:1901
~Mat4()
Definition: CUMat4.h:187
Mat4 & add(float scalar)
Definition: CUMat4.h:942
static Vec2 * transformVector(const Mat4 &mat, const Vec2 &vec, Vec2 *dst)
static Mat4 createScale(const Vec3 &scale)
Definition: CUMat4.h:494
Mat4 & operator+=(const Mat4 &mat)
Definition: CUMat4.h:1093
Mat4 & rotateZ(float angle)
Definition: CUMat4.h:1887
static const Mat4 ONE
Definition: CUMat4.h:103
static Mat4 createRotationY(float angle)
Definition: CUMat4.h:599
bool isExactly(const Mat4 &mat) const
Mat4 & translate(float tx, float ty, float tz)
Definition: CUMat4.h:1961
static Mat4 * subtract(const Mat4 &mat, float scalar, Mat4 *dst)
static Mat4 * rotateX(const Mat4 &mat, float angle, Mat4 *dst)
Definition: CUMat4.h:1636
Mat4 & rotateY(float angle)
Definition: CUMat4.h:1871
Mat4 & operator-=(const Mat4 &mat)
Definition: CUMat4.h:1104
static Mat4 createScale(float scale)
Definition: CUMat4.h:446
Mat4 & rotateX(float angle)
Definition: CUMat4.h:1855
Mat4 & negate()
Definition: CUMat4.h:1009
Mat4 & operator*=(float scalar)
Definition: CUMat4.h:1129
Mat4 & multiply(float scalar)
Definition: CUMat4.h:986
static Mat4 * rotate(const Mat4 &mat, const Quaternion &quat, Mat4 *dst)
Definition: CUMat4.h:1593
static Mat4 * scale(const Mat4 &mat, float value, Mat4 *dst)
Definition: CUMat4.h:1697
Vec3 getRightVector() const
Mat4 & transpose()
Definition: CUMat4.h:1062
static Mat4 * translate(const Mat4 &mat, float tx, float ty, float tz, Mat4 *dst)
Definition: CUMat4.h:1777
Mat4 & rotate(const Vec3 &axis, float angle)
Definition: CUMat4.h:1839
static Mat4 * scale(const Mat4 &mat, float sx, float sy, float sz, Mat4 *dst)
Definition: CUMat4.h:1737
Mat4 getInverse() const
Definition: CUMat4.h:1047
const Mat4 operator*(const Mat4 &mat) const
Definition: CUMat4.h:1184
static Mat4 createOrthographic(float width, float height, float zNearPlane, float zFarPlane)
Definition: CUMat4.h:333
static Mat4 createTranslation(float tx, float ty, float tz)
Definition: CUMat4.h:676
static Mat4 * rotateZ(const Mat4 &mat, float angle, Mat4 *dst)
Definition: CUMat4.h:1678
Mat4 & subtract(const Mat4 &mat)
Definition: CUMat4.h:975
static bool decompose(const Mat4 &mat, Vec3 *scale, Quaternion *rot, Vec3 *trans)
Mat4 & multiply(const Mat4 &mat)
Definition: CUMat4.h:1000
const Mat4 operator-(const Mat4 &mat) const
Definition: CUMat4.h:1156
bool isInvertible(float variance=CU_MATH_EPSILON) const
Definition: CUMat4.h:1285
Definition: CUVec4.h:64
static Mat4 createPerspective(float fieldOfView, float aspectRatio, float zNearPlane, float zFarPlane)
Definition: CUMat4.h:281
const Mat4 operator+(const Mat4 &mat) const
Definition: CUMat4.h:1142
std::string toString(bool verbose=false) const
Mat4 & operator=(const float *array)
Definition: CUMat4.h:734
Mat4 & operator=(const Quaternion &quat)
Definition: CUMat4.h:745
Mat4 & add(const Mat4 &mat)
Definition: CUMat4.h:953
static Mat4 * rotateY(const Mat4 &mat, float angle, Mat4 *dst)
Definition: CUMat4.h:1657
Definition: CURect.h:45
bool equals(const Mat4 &mat, float variance=CU_MATH_EPSILON) const
static const Mat4 IDENTITY
Definition: CUMat4.h:105
static Mat4 * scale(const Mat4 &mat, const Vec3 &s, Mat4 *dst)
Definition: CUMat4.h:1716
static Mat4 * createOrthographic(float width, float height, float zNearPlane, float zFarPlane, Mat4 *dst)
Definition: CUMat4.h:366
const Mat4 operator*(float scalar) const
Definition: CUMat4.h:1198
static Mat4 createLookAt(float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ, float upX, float upY, float upZ)
Definition: CUMat4.h:234
Mat4 & subtract(float scalar)
Definition: CUMat4.h:964
Mat4 getTranspose() const
Definition: CUMat4.h:1077
Mat4 & setIdentity()
Definition: CUVec3.h:61
Mat4 getNegation() const
Definition: CUMat4.h:1020
Mat4 & scale(float sx, float sy, float sz)
Definition: CUMat4.h:1931
static Mat4 createRotation(const Quaternion &quat)
Definition: CUMat4.h:516
Mat4 & translate(const Vec3 &t)
Definition: CUMat4.h:1945
static Mat4 * add(const Mat4 &mat, float scalar, Mat4 *dst)
const Mat4 operator-() const
Definition: CUMat4.h:1168
Mat4 & rotate(const Quaternion &q)
Definition: CUMat4.h:1822
Definition: CUAction.h:51
Vec3 getDownVector() const
Definition: CUQuaternion.h:97
Definition: CUMat4.h:83
static Mat4 createTranslation(const Vec3 &trans)
Definition: CUMat4.h:652
static Mat4 * translate(const Mat4 &mat, const Vec3 &t, Mat4 *dst)
Definition: CUMat4.h:1756
Vec3 getUpVector() const
static Mat4 createRotationZ(float angle)
Definition: CUMat4.h:627
static const Mat4 ZERO
Definition: CUMat4.h:101
static Mat4 createLookAt(const Vec3 &eye, const Vec3 &target, const Vec3 &up)
Definition: CUMat4.h:201
Quaternion getRotation() const
Vec3 getLeftVector() const
static Mat4 * rotate(const Mat4 &mat, const Vec3 &axis, float angle, Mat4 *dst)
Definition: CUMat4.h:1615
Mat4 & setZero()
bool operator==(const Mat4 &mat) const
Definition: CUMat4.h:1242
Mat4 & operator*=(const Mat4 &mat)
Definition: CUMat4.h:1118
Mat4 & invert()
Definition: CUMat4.h:1034
bool operator!=(const Mat4 &mat) const
Definition: CUMat4.h:1256