42 #ifdef CU_MATH_VECTOR_APPLE
45 #include <Accelerate/Accelerate.h>
47 #ifdef CU_MATH_VECTOR_SSE
48 #include <xmmintrin.h>
51 #if defined (__WINDOWS__)
56 #include "CUMathBase.h"
95 #if defined CU_MATH_VECTOR_APPLE
100 #elif defined CU_MATH_VECTOR_SSE
101 __declspec(align(16))
union {
118 #pragma mark Constructors
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);
168 Mat4(
const float* mat);
200 #pragma mark Static Constructors
244 float targetX,
float targetY,
float targetZ,
245 float upX,
float upY,
float upZ) {
248 targetX, targetY, targetZ,
249 upX, upY, upZ, &result));
269 float targetX,
float targetY,
float targetZ,
270 float upX,
float upY,
float upZ,
Mat4* dst);
291 float zNearPlane,
float zFarPlane) {
293 return *(
createPerspective(fieldOfView, aspectRatio, zNearPlane, zFarPlane, &result));
315 float zNearPlane,
float zFarPlane,
Mat4* dst);
343 float zNearPlane,
float zFarPlane) {
376 float zNearPlane,
float zFarPlane,
Mat4* dst) {
377 float halfWidth = width / 2.0f;
378 float halfHeight = height / 2.0f;
380 zNearPlane, zFarPlane, dst);
411 float zNearPlane,
float zFarPlane) {
446 float zNearPlane,
float zFarPlane,
Mat4* dst);
724 memcpy(this->m, mat.m,
sizeof(
float)*16);
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);
834 #pragma mark Static Arithmetic
943 #pragma mark Arithmetic
952 return *(
add(*
this,scalar,
this));
963 return *(
add(*
this,mat,
this));
974 return *(
subtract(*
this,scalar,
this));
996 return *(
multiply(*
this,scalar,
this));
1010 return *(
multiply(*
this,mat,
this));
1019 return *(
negate(*
this,
this));
1044 return *(
invert(*
this,
this));
1094 #pragma mark Operators
1153 return result.
add(mat);
1214 #pragma mark Comparisons
1238 bool equals(
const Mat4& mat,
float variance=CU_MATH_EPSILON)
const;
1271 #pragma mark Matrix Attributes
1307 bool isOrthogonal(
float variance=CU_MATH_EPSILON)
const;
1396 #pragma mark Static Vector Operations
1483 #pragma mark Vector Operations
1575 #pragma mark Static Matrix Transforms
1806 #pragma mark Matrix Transforms
1818 return *(
rotate(*
this,q,
this));
1835 return *(
rotate(*
this,axis,angle,
this));
1851 return *(
rotateX(*
this,angle,
this));
1867 return *(
rotateY(*
this,angle,
this));
1883 return *(
rotateZ(*
this,angle,
this));
1897 return *(
scale(*
this,value,
this));
1911 return *(
scale(*
this,s,
this));
1927 return *(
scale(*
this,sx,sy,sz,
this));
1957 return *(
translate(*
this,tx,ty,tz,
this));
1962 #pragma mark Conversion Methods
1973 std::string
toString(
bool verbose =
false)
const;
2021 #pragma mark Vector Operations
static Mat4 createRotationX(float angle)
Definition: CUMat4.h:580
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
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
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
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 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
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
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
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