CUGL 1.3
Cornell University Game Library
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
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 
98  float m[16];
99 #endif
100 
102  static const Mat4 ZERO;
104  static const Mat4 ONE;
106  static const Mat4 IDENTITY;
107 
108 
109 #pragma mark -
110 #pragma mark Constructors
111 public:
120  Mat4();
121 
142  Mat4(float m11, float m12, float m13, float m14,
143  float m21, float m22, float m23, float m24,
144  float m31, float m32, float m33, float m34,
145  float m41, float m42, float m43, float m44);
146 
160  Mat4(const float* mat);
161 
167  Mat4(const Mat4& copy);
168 
174  Mat4(Mat4&& copy);
175 
181  Mat4(const Quaternion& rotation) {
182  createRotation(rotation, this);
183  }
184 
188  ~Mat4() {}
189 
190 
191 #pragma mark -
192 #pragma mark Static Constructors
193 
202  static Mat4 createLookAt(const Vec3& eye, const Vec3& target, const Vec3& up) {
203  Mat4 result;
204  return *(createLookAt(eye,target,up,&result));
205  }
206 
207 
218  static Mat4* createLookAt(const Vec3& eye, const Vec3& target, const Vec3& up, Mat4* dst);
219 
235  static Mat4 createLookAt(float eyeX, float eyeY, float eyeZ,
236  float targetX, float targetY, float targetZ,
237  float upX, float upY, float upZ) {
238  Mat4 result;
239  return *(createLookAt(eyeX, eyeY, eyeZ,
240  targetX, targetY, targetZ,
241  upX, upY, upZ, &result));
242  }
243 
260  static Mat4* createLookAt(float eyeX, float eyeY, float eyeZ,
261  float targetX, float targetY, float targetZ,
262  float upX, float upY, float upZ, Mat4* dst);
263 
264 
282  static Mat4 createPerspective(float fieldOfView, float aspectRatio,
283  float zNearPlane, float zFarPlane) {
284  Mat4 result;
285  return *(createPerspective(fieldOfView, aspectRatio, zNearPlane, zFarPlane, &result));
286  }
287 
306  static Mat4* createPerspective(float fieldOfView, float aspectRatio,
307  float zNearPlane, float zFarPlane, Mat4* dst);
308 
334  static Mat4 createOrthographic(float width, float height,
335  float zNearPlane, float zFarPlane) {
336  Mat4 result;
337  return *(createOrthographic(width, height, zNearPlane, zFarPlane, &result));
338  }
339 
340 
367  static Mat4* createOrthographic(float width, float height,
368  float zNearPlane, float zFarPlane, Mat4* dst) {
369  float halfWidth = width / 2.0f;
370  float halfHeight = height / 2.0f;
371  return createOrthographicOffCenter(-halfWidth, halfWidth, -halfHeight, halfHeight,
372  zNearPlane, zFarPlane, dst);
373  }
374 
402  static Mat4 createOrthographicOffCenter(float left, float right, float bottom, float top,
403  float zNearPlane, float zFarPlane) {
404  Mat4 result;
405  return *(createOrthographicOffCenter(left, right, bottom, top, zNearPlane, zFarPlane, &result));
406  }
407 
408 
437  static Mat4* createOrthographicOffCenter(float left, float right, float bottom, float top,
438  float zNearPlane, float zFarPlane, Mat4* dst);
439 
447  static Mat4 createScale(float scale) {
448  Mat4 result;
449  return *(createScale(scale,&result));
450  }
451 
460  static Mat4* createScale(float scale, Mat4* dst);
461 
471  static Mat4 createScale(float sx, float sy, float sz) {
472  Mat4 result;
473  return *(createScale(sx,sy,sz,&result));
474  }
475 
486  static Mat4* createScale(float sx, float sy, float sz, Mat4* dst);
487 
495  static Mat4 createScale(const Vec3& scale) {
496  Mat4 result;
497  return *(createScale(scale,&result));
498  }
499 
508  static Mat4* createScale(const Vec3& scale, Mat4* dst);
509 
517  static Mat4 createRotation(const Quaternion& quat) {
518  Mat4 result;
519  return *(createRotation(quat,&result));
520  }
521 
530  static Mat4* createRotation(const Quaternion& quat, Mat4* dst);
531 
543  static Mat4 createRotation(const Vec3& axis, float angle) {
544  Mat4 result;
545  return *(createRotation(axis,angle,&result));
546  }
547 
560  static Mat4* createRotation(const Vec3& axis, float angle, Mat4* dst);
561 
572  static Mat4 createRotationX(float angle) {
573  Mat4 result;
574  return *(createRotationX(angle,&result));
575  }
576 
588  static Mat4* createRotationX(float angle, Mat4* dst);
589 
600  static Mat4 createRotationY(float angle) {
601  Mat4 result;
602  return *(createRotationY(angle,&result));
603  }
604 
616  static Mat4* createRotationY(float angle, Mat4* dst);
617 
628  static Mat4 createRotationZ(float angle) {
629  Mat4 result;
630  return *(createRotationZ(angle,&result));
631  }
632 
644  static Mat4* createRotationZ(float angle, Mat4* dst);
645 
653  static Mat4 createTranslation(const Vec3& trans) {
654  Mat4 result;
655  return *(createTranslation(trans,&result));
656  }
657 
666  static Mat4* createTranslation(const Vec3& trans, Mat4* dst);
667 
677  static Mat4 createTranslation(float tx, float ty, float tz) {
678  Mat4 result;
679  return *(createTranslation(tx,ty,tz,&result));
680  }
681 
692  static Mat4* createTranslation(float tx, float ty, float tz, Mat4* dst);
693 
694 
695 #pragma mark -
696 #pragma mark Setters
697 
704  Mat4& operator=(const Mat4& mat) {
705  return set(mat);
706  }
707 
715  Mat4& operator=(Mat4&& mat) {
716  memcpy(this->m, mat.m, sizeof(float)*16);
717  return *this;
718  }
719 
735  Mat4& operator=(const float* array) {
736  return set(array);
737  }
738 
746  Mat4& operator=(const Quaternion& quat) {
747  return set(quat);
748  }
749 
772  Mat4& set(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24,
773  float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44);
774 
790  Mat4& set(const float* mat);
791 
799  Mat4& set(const Quaternion& quat);
800 
808  Mat4& set(const Mat4& mat);
809 
815  Mat4& setIdentity();
816 
822  Mat4& setZero();
823 
824 
825 #pragma mark -
826 #pragma mark Static Arithmetic
827 
837  static Mat4* add(const Mat4& mat, float scalar, Mat4* dst);
838 
848  static Mat4* add(const Mat4& m1, const Mat4& m2, Mat4* dst);
849 
859  static Mat4* subtract(const Mat4& mat, float scalar, Mat4* dst);
860 
870  static Mat4* subtract(const Mat4& m1, const Mat4& m2, Mat4* dst);
871 
881  static Mat4* multiply(const Mat4& mat, float scalar, Mat4* dst);
882 
895  static Mat4* multiply(const Mat4& m1, const Mat4& m2, Mat4* dst);
896 
905  static Mat4* negate(const Mat4& m1, Mat4* dst);
906 
918  static Mat4* invert(const Mat4& m1, Mat4* dst);
919 
932  static Mat4* transpose(const Mat4& m1, Mat4* dst);
933 
934 #pragma mark -
935 #pragma mark Arithmetic
936 
943  Mat4& add(float scalar) {
944  return *(add(*this,scalar,this));
945  }
946 
954  Mat4& add(const Mat4& mat) {
955  return *(add(*this,mat,this));
956  }
957 
965  Mat4& subtract(float scalar) {
966  return *(subtract(*this,scalar,this));
967  }
968 
976  Mat4& subtract(const Mat4& mat) {
977  return *(subtract(*this,mat,this));
978  }
979 
987  Mat4& multiply(float scalar) {
988  return *(multiply(*this,scalar,this));
989  }
990 
1001  Mat4& multiply(const Mat4& mat) {
1002  return *(multiply(*this,mat,this));
1003  }
1004 
1011  return *(negate(*this,this));
1012  }
1013 
1021  Mat4 getNegation() const {
1022  Mat4 result;
1023  negate(*this,&result);
1024  return result;
1025  }
1026 
1036  return *(invert(*this,this));
1037  }
1038 
1048  Mat4 getInverse() const {
1049  Mat4 result;
1050  invert(*this,&result);
1051  return result;
1052  }
1053 
1064  return *(transpose(*this,this));
1065  }
1066 
1078  Mat4 getTranspose() const {
1079  Mat4 result;
1080  transpose(*this,&result);
1081  return result;
1082  }
1083 
1084 
1085 #pragma mark -
1086 #pragma mark Operators
1087 
1094  Mat4& operator+=(const Mat4& mat) {
1095  return add(mat);
1096  }
1097 
1105  Mat4& operator-=(const Mat4& mat) {
1106  return subtract(mat);
1107  }
1108 
1119  Mat4& operator*=(const Mat4& mat) {
1120  return multiply(mat);
1121  }
1122 
1130  Mat4& operator*=(float scalar) {
1131  return multiply(scalar);
1132  }
1133 
1143  const Mat4 operator+(const Mat4& mat) const {
1144  Mat4 result(*this);
1145  return result.add(mat);
1146  }
1147 
1157  const Mat4 operator-(const Mat4& mat) const {
1158  Mat4 result(*this);
1159  return result.subtract(mat);
1160  }
1161 
1169  const Mat4 operator-() const {
1170  return getNegation();
1171  }
1172 
1185  const Mat4 operator*(const Mat4& mat) const {
1186  Mat4 result(*this);
1187  return result.multiply(mat);
1188  }
1189 
1199  const Mat4 operator*(float scalar) const {
1200  Mat4 result(*this);
1201  return result.multiply(scalar);
1202  }
1203 
1204 
1205 #pragma mark -
1206 #pragma mark Comparisons
1207 
1218  bool isExactly(const Mat4& mat) const;
1219 
1230  bool equals(const Mat4& mat, float variance=CU_MATH_EPSILON) const;
1231 
1243  bool operator==(const Mat4& mat) const {
1244  return isExactly(mat);
1245  }
1246 
1257  bool operator!=(const Mat4& mat) const {
1258  return !isExactly(mat);
1259  }
1260 
1261 
1262 #pragma mark -
1263 #pragma mark Matrix Attributes
1264 
1275  bool isIdentity(float variance=CU_MATH_EPSILON) const;
1276 
1286  bool isInvertible(float variance=CU_MATH_EPSILON) const {
1287  return fabsf(getDeterminant()) > variance;
1288  }
1289 
1299  bool isOrthogonal(float variance=CU_MATH_EPSILON) const;
1300 
1306  float getDeterminant() const;
1307 
1322  Vec3 getScale() const;
1323 
1332  Quaternion getRotation() const;
1333 
1343  Vec3 getTranslation() const;
1344 
1350  Vec3 getUpVector() const;
1351 
1357  Vec3 getDownVector() const;
1363  Vec3 getLeftVector() const;
1364 
1370  Vec3 getRightVector() const;
1371 
1377  Vec3 getForwardVector() const;
1378 
1384  Vec3 getBackVector() const;
1385 
1386 
1387 #pragma mark -
1388 #pragma mark Static Vector Operations
1389 
1401  static Vec2* transform(const Mat4& mat, const Vec2& point, Vec2* dst);
1402 
1415  static Rect* transform(const Mat4& mat, const Rect& rect, Rect* dst);
1416 
1429  static Vec2* transformVector(const Mat4& mat, const Vec2& vec, Vec2* dst);
1430 
1443  static Vec3* transform(const Mat4& mat, const Vec3& point, Vec3* dst);
1444 
1457  static Vec3* transformVector(const Mat4& mat, const Vec3& vec, Vec3* dst);
1458 
1471  static Vec4* transform(const Mat4& mat, const Vec4& vec, Vec4* dst);
1472 
1486  static float* transform(const Mat4& mat, float const* input, float* output, size_t size);
1487 
1488 
1489 #pragma mark -
1490 #pragma mark Vector Operations
1491 
1504  Vec2 transform(const Vec2& point) const;
1505 
1519  Rect transform(const Rect& rect) const;
1520 
1534  Vec2 transformVector(const Vec2& vec) const;
1535 
1549  Vec3 transform(const Vec3& point) const;
1550 
1564  Vec3 transformVector(const Vec3& vec) const;
1565 
1579  Vec4 transform(const Vec4& vec) const;
1580 
1581 #pragma mark -
1582 #pragma mark Static Matrix Transforms
1583 
1595  static Mat4* rotate(const Mat4& mat, const Quaternion& quat, Mat4* dst) {
1596  Mat4 result;
1597  createRotation(quat, &result);
1598  multiply(mat, result, dst);
1599  return dst;
1600  }
1601 
1617  static Mat4* rotate(const Mat4& mat, const Vec3& axis, float angle, Mat4* dst) {
1618  Mat4 result;
1619  createRotation(axis, angle, &result);
1620  multiply(mat, result, dst);
1621  return dst;
1622  }
1623 
1638  static Mat4* rotateX(const Mat4& mat, float angle, Mat4* dst) {
1639  Mat4 result;
1640  createRotationX(angle, &result);
1641  multiply(mat, result, dst);
1642  return dst;
1643  }
1644 
1659  static Mat4* rotateY(const Mat4& mat, float angle, Mat4* dst) {
1660  Mat4 result;
1661  createRotationY(angle, &result);
1662  multiply(mat, result, dst);
1663  return dst;
1664  }
1665 
1680  static Mat4* rotateZ(const Mat4& mat, float angle, Mat4* dst) {
1681  Mat4 result;
1682  createRotationZ(angle, &result);
1683  multiply(mat, result, dst);
1684  return dst;
1685  }
1686 
1699  static Mat4* scale(const Mat4& mat, float value, Mat4* dst) {
1700  Mat4 result;
1701  createScale(value, &result);
1702  multiply(mat, result, dst);
1703  return dst;
1704  }
1705 
1718  static Mat4* scale(const Mat4& mat, const Vec3& s, Mat4* dst) {
1719  Mat4 result;
1720  createScale(s, &result);
1721  multiply(mat, result, dst);
1722  return dst;
1723  }
1724 
1739  static Mat4* scale(const Mat4& mat, float sx, float sy, float sz, Mat4* dst) {
1740  Mat4 result;
1741  createScale(sx,sy,sz, &result);
1742  multiply(mat, result, dst);
1743  return dst;
1744  }
1745 
1758  static Mat4* translate(const Mat4& mat, const Vec3& t, Mat4* dst) {
1759  Mat4 result;
1760  createTranslation(t, &result);
1761  multiply(mat, result, dst);
1762  return dst;
1763  }
1764 
1779  static Mat4* translate(const Mat4& mat, float tx, float ty, float tz, Mat4* dst) {
1780  Mat4 result;
1781  createTranslation(tx,ty,tz, &result);
1782  multiply(mat, result, dst);
1783  return dst;
1784  }
1785 
1809  static bool decompose(const Mat4& mat, Vec3* scale, Quaternion* rot, Vec3* trans);
1810 
1811 
1812 #pragma mark -
1813 #pragma mark Matrix Transforms
1814 
1824  Mat4& rotate(const Quaternion& q) {
1825  return *(rotate(*this,q,this));
1826  }
1827 
1841  Mat4& rotate(const Vec3& axis, float angle) {
1842  return *(rotate(*this,axis,angle,this));
1843  }
1844 
1857  Mat4& rotateX(float angle) {
1858  return *(rotateX(*this,angle,this));
1859  }
1860 
1873  Mat4& rotateY(float angle) {
1874  return *(rotateY(*this,angle,this));
1875  }
1876 
1889  Mat4& rotateZ(float angle) {
1890  return *(rotateZ(*this,angle,this));
1891  }
1892 
1903  Mat4& scale(float value) {
1904  return *(scale(*this,value,this));
1905  }
1906 
1917  Mat4& scale(const Vec3& s) {
1918  return *(scale(*this,s,this));
1919  }
1920 
1933  Mat4& scale(float sx, float sy, float sz) {
1934  return *(scale(*this,sx,sy,sz,this));
1935  }
1936 
1947  Mat4& translate(const Vec3& t) {
1948  return *(translate(*this,t,this));
1949  }
1950 
1963  Mat4& translate(float tx, float ty, float tz) {
1964  return *(translate(*this,tx,ty,tz,this));
1965  }
1966 
1967 
1968 #pragma mark -
1969 #pragma mark Conversion Methods
1970 
1980  std::string toString(bool verbose = false) const;
1981 
1983  operator std::string() const { return toString(); }
1984 
1993  operator Affine2() const;
1994 
2002  explicit Mat4(const Affine2& aff);
2003 
2013  Mat4& operator= (const Affine2& aff);
2014 
2024  Mat4& set(const Affine2& aff);
2025 };
2026 
2027 #pragma mark -
2028 #pragma mark Vector Operations
2029 // To avoid confusion, we NEVER support vector on the right ops.
2030 
2042 inline Vec2& operator*=(Vec2& v, const Mat4& m) {
2043  return *(Mat4::transform(m,v,&v));
2044 }
2045 
2057 inline const Vec2 operator*(const Vec2& v, const Mat4& m) {
2058  return m.transform(v);
2059 }
2060 
2072 inline Vec3& operator*=(Vec3& v, const Mat4& m) {
2073  return *(Mat4::transform(m,v,&v));
2074 }
2075 
2087 inline const Vec3 operator*(const Vec3& v, const Mat4& m) {
2088  return m.transform(v);
2089 }
2090 
2102 inline Vec4& operator*=(Vec4& v, const Mat4& m) {
2103  return *(Mat4::transform(m,v,&v));
2104 }
2105 
2117 inline const Vec4 operator*(const Vec4& v, const Mat4& m) {
2118  return m.transform(v);
2119 }
2120 
2129 inline const Mat4 operator*(float scalar, const Mat4& m) {
2130  Mat4 result(m);
2131  return result.multiply(scalar);
2132 }
2133 
2134 }
2135 
2136 #endif /* __CU_MAT4_H__ */
cugl::Mat4::Mat4
Mat4(const Quaternion &rotation)
Definition: CUMat4.h:181
cugl::Mat4::createOrthographicOffCenter
static Mat4 createOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane)
Definition: CUMat4.h:402
cugl::Mat4::scale
static Mat4 * scale(const Mat4 &mat, const Vec3 &s, Mat4 *dst)
Definition: CUMat4.h:1718
cugl::Mat4::createRotationZ
static Mat4 createRotationZ(float angle)
Definition: CUMat4.h:628
cugl::Mat4::operator*
const Mat4 operator*(float scalar) const
Definition: CUMat4.h:1199
cugl::Mat4::translate
Mat4 & translate(const Vec3 &t)
Definition: CUMat4.h:1947
cugl::Mat4::getDeterminant
float getDeterminant() const
cugl::Mat4::transform
static Vec2 * transform(const Mat4 &mat, const Vec2 &point, Vec2 *dst)
cugl::Mat4::rotateX
static Mat4 * rotateX(const Mat4 &mat, float angle, Mat4 *dst)
Definition: CUMat4.h:1638
cugl::Mat4::operator==
bool operator==(const Mat4 &mat) const
Definition: CUMat4.h:1243
cugl::Mat4::operator*
const Mat4 operator*(const Mat4 &mat) const
Definition: CUMat4.h:1185
cugl::Vec4
Definition: CUVec4.h:64
cugl::Mat4::createRotationY
static Mat4 createRotationY(float angle)
Definition: CUMat4.h:600
cugl::Mat4::multiply
static Mat4 * multiply(const Mat4 &mat, float scalar, Mat4 *dst)
cugl::Mat4::equals
bool equals(const Mat4 &mat, float variance=CU_MATH_EPSILON) const
cugl::Mat4::createScale
static Mat4 createScale(const Vec3 &scale)
Definition: CUMat4.h:495
cugl::Mat4::rotateY
static Mat4 * rotateY(const Mat4 &mat, float angle, Mat4 *dst)
Definition: CUMat4.h:1659
cugl::Mat4::translate
Mat4 & translate(float tx, float ty, float tz)
Definition: CUMat4.h:1963
cugl::Mat4::scale
static Mat4 * scale(const Mat4 &mat, float value, Mat4 *dst)
Definition: CUMat4.h:1699
cugl::Mat4::getRotation
Quaternion getRotation() const
cugl::Mat4::rotate
Mat4 & rotate(const Quaternion &q)
Definition: CUMat4.h:1824
cugl::Mat4::transpose
Mat4 & transpose()
Definition: CUMat4.h:1063
cugl::Mat4::add
static Mat4 * add(const Mat4 &mat, float scalar, Mat4 *dst)
cugl::Mat4::operator-
const Mat4 operator-() const
Definition: CUMat4.h:1169
cugl::Mat4::IDENTITY
static const Mat4 IDENTITY
Definition: CUMat4.h:106
cugl::Mat4::setIdentity
Mat4 & setIdentity()
cugl::Mat4::subtract
Mat4 & subtract(float scalar)
Definition: CUMat4.h:965
cugl::Mat4::operator+=
Mat4 & operator+=(const Mat4 &mat)
Definition: CUMat4.h:1094
cugl::Affine2
Definition: CUAffine2.h:63
cugl::Mat4::rotateZ
Mat4 & rotateZ(float angle)
Definition: CUMat4.h:1889
cugl::Mat4::operator=
Mat4 & operator=(const Quaternion &quat)
Definition: CUMat4.h:746
cugl::Mat4::scale
Mat4 & scale(const Vec3 &s)
Definition: CUMat4.h:1917
cugl::Mat4::createLookAt
static Mat4 createLookAt(const Vec3 &eye, const Vec3 &target, const Vec3 &up)
Definition: CUMat4.h:202
cugl::Mat4::transformVector
static Vec2 * transformVector(const Mat4 &mat, const Vec2 &vec, Vec2 *dst)
cugl::Mat4::createRotationX
static Mat4 createRotationX(float angle)
Definition: CUMat4.h:572
cugl::Mat4::translate
static Mat4 * translate(const Mat4 &mat, float tx, float ty, float tz, Mat4 *dst)
Definition: CUMat4.h:1779
cugl::Mat4::multiply
Mat4 & multiply(float scalar)
Definition: CUMat4.h:987
cugl::Mat4::operator=
Mat4 & operator=(Mat4 &&mat)
Definition: CUMat4.h:715
cugl::Mat4::getTranspose
Mat4 getTranspose() const
Definition: CUMat4.h:1078
cugl::Mat4::operator=
Mat4 & operator=(const float *array)
Definition: CUMat4.h:735
cugl::Mat4::createTranslation
static Mat4 createTranslation(float tx, float ty, float tz)
Definition: CUMat4.h:677
cugl::Mat4::scale
Mat4 & scale(float value)
Definition: CUMat4.h:1903
cugl::Mat4::rotate
Mat4 & rotate(const Vec3 &axis, float angle)
Definition: CUMat4.h:1841
cugl::Rect
Definition: CURect.h:45
cugl::Mat4
Definition: CUMat4.h:83
cugl::Mat4::createTranslation
static Mat4 createTranslation(const Vec3 &trans)
Definition: CUMat4.h:653
cugl::Mat4::add
Mat4 & add(float scalar)
Definition: CUMat4.h:943
cugl::Mat4::setZero
Mat4 & setZero()
cugl::Mat4::operator*=
Mat4 & operator*=(float scalar)
Definition: CUMat4.h:1130
cugl::Mat4::operator-
const Mat4 operator-(const Mat4 &mat) const
Definition: CUMat4.h:1157
cugl::Mat4::operator-=
Mat4 & operator-=(const Mat4 &mat)
Definition: CUMat4.h:1105
cugl::Mat4::getUpVector
Vec3 getUpVector() const
cugl::Mat4::decompose
static bool decompose(const Mat4 &mat, Vec3 *scale, Quaternion *rot, Vec3 *trans)
cugl::Mat4::isOrthogonal
bool isOrthogonal(float variance=CU_MATH_EPSILON) const
cugl::Mat4::ZERO
static const Mat4 ZERO
Definition: CUMat4.h:102
cugl::Mat4::getTranslation
Vec3 getTranslation() const
cugl::Mat4::ONE
static const Mat4 ONE
Definition: CUMat4.h:104
cugl::Mat4::multiply
Mat4 & multiply(const Mat4 &mat)
Definition: CUMat4.h:1001
cugl::Mat4::createOrthographic
static Mat4 * createOrthographic(float width, float height, float zNearPlane, float zFarPlane, Mat4 *dst)
Definition: CUMat4.h:367
cugl::Mat4::isExactly
bool isExactly(const Mat4 &mat) const
cugl::Mat4::m
float m[16]
Definition: CUMat4.h:98
cugl::Mat4::operator*=
Mat4 & operator*=(const Mat4 &mat)
Definition: CUMat4.h:1119
cugl::Mat4::createRotation
static Mat4 createRotation(const Quaternion &quat)
Definition: CUMat4.h:517
cugl::Mat4::createLookAt
static Mat4 createLookAt(float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ, float upX, float upY, float upZ)
Definition: CUMat4.h:235
cugl::Mat4::rotateZ
static Mat4 * rotateZ(const Mat4 &mat, float angle, Mat4 *dst)
Definition: CUMat4.h:1680
cugl::Mat4::rotateX
Mat4 & rotateX(float angle)
Definition: CUMat4.h:1857
cugl::Mat4::getScale
Vec3 getScale() const
cugl::Mat4::scale
static Mat4 * scale(const Mat4 &mat, float sx, float sy, float sz, Mat4 *dst)
Definition: CUMat4.h:1739
cugl::Mat4::createOrthographic
static Mat4 createOrthographic(float width, float height, float zNearPlane, float zFarPlane)
Definition: CUMat4.h:334
cugl::Mat4::createScale
static Mat4 createScale(float sx, float sy, float sz)
Definition: CUMat4.h:471
cugl::Vec2
Definition: CUVec2.h:61
cugl::Mat4::createRotation
static Mat4 createRotation(const Vec3 &axis, float angle)
Definition: CUMat4.h:543
cugl::Mat4::getDownVector
Vec3 getDownVector() const
cugl::Mat4::translate
static Mat4 * translate(const Mat4 &mat, const Vec3 &t, Mat4 *dst)
Definition: CUMat4.h:1758
cugl::Mat4::isInvertible
bool isInvertible(float variance=CU_MATH_EPSILON) const
Definition: CUMat4.h:1286
cugl::Mat4::negate
Mat4 & negate()
Definition: CUMat4.h:1010
cugl::Mat4::operator!=
bool operator!=(const Mat4 &mat) const
Definition: CUMat4.h:1257
cugl::Mat4::rotateY
Mat4 & rotateY(float angle)
Definition: CUMat4.h:1873
cugl::Mat4::subtract
static Mat4 * subtract(const Mat4 &mat, float scalar, Mat4 *dst)
cugl::Mat4::isIdentity
bool isIdentity(float variance=CU_MATH_EPSILON) const
cugl::Mat4::scale
Mat4 & scale(float sx, float sy, float sz)
Definition: CUMat4.h:1933
cugl::Mat4::operator+
const Mat4 operator+(const Mat4 &mat) const
Definition: CUMat4.h:1143
cugl::Mat4::subtract
Mat4 & subtract(const Mat4 &mat)
Definition: CUMat4.h:976
cugl::Mat4::getInverse
Mat4 getInverse() const
Definition: CUMat4.h:1048
cugl::Mat4::~Mat4
~Mat4()
Definition: CUMat4.h:188
cugl::Quaternion
Definition: CUQuaternion.h:97
cugl::Mat4::getLeftVector
Vec3 getLeftVector() const
cugl::Mat4::createScale
static Mat4 createScale(float scale)
Definition: CUMat4.h:447
cugl::Mat4::operator=
Mat4 & operator=(const Mat4 &mat)
Definition: CUMat4.h:704
cugl::Mat4::add
Mat4 & add(const Mat4 &mat)
Definition: CUMat4.h:954
cugl::Mat4::set
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)
cugl::Mat4::rotate
static Mat4 * rotate(const Mat4 &mat, const Quaternion &quat, Mat4 *dst)
Definition: CUMat4.h:1595
cugl::Vec3
Definition: CUVec3.h:61
cugl::Mat4::getNegation
Mat4 getNegation() const
Definition: CUMat4.h:1021
cugl::Mat4::getRightVector
Vec3 getRightVector() const
cugl::Mat4::getBackVector
Vec3 getBackVector() const
cugl::Mat4::createPerspective
static Mat4 createPerspective(float fieldOfView, float aspectRatio, float zNearPlane, float zFarPlane)
Definition: CUMat4.h:282
cugl::Mat4::getForwardVector
Vec3 getForwardVector() const
cugl::Mat4::invert
Mat4 & invert()
Definition: CUMat4.h:1035
cugl::Mat4::rotate
static Mat4 * rotate(const Mat4 &mat, const Vec3 &axis, float angle, Mat4 *dst)
Definition: CUMat4.h:1617
cugl::Mat4::toString
std::string toString(bool verbose=false) const
cugl::Mat4::Mat4
Mat4()