 |
CUGL 1.3
Cornell University Game Library
|
47 #include "CUMathBase.h"
86 #if defined CU_MATH_VECTOR_SSE
87 __attribute__((__aligned__(16)))
union {
91 #elif defined CU_MATH_VECTOR_NEON64
92 __attribute__((__aligned__(16)))
union {
110 #pragma mark Constructors
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);
160 Mat4(
const float* mat);
192 #pragma mark Static Constructors
236 float targetX,
float targetY,
float targetZ,
237 float upX,
float upY,
float upZ) {
240 targetX, targetY, targetZ,
241 upX, upY, upZ, &result));
261 float targetX,
float targetY,
float targetZ,
262 float upX,
float upY,
float upZ,
Mat4* dst);
283 float zNearPlane,
float zFarPlane) {
285 return *(
createPerspective(fieldOfView, aspectRatio, zNearPlane, zFarPlane, &result));
307 float zNearPlane,
float zFarPlane,
Mat4* dst);
335 float zNearPlane,
float zFarPlane) {
368 float zNearPlane,
float zFarPlane,
Mat4* dst) {
369 float halfWidth = width / 2.0f;
370 float halfHeight = height / 2.0f;
372 zNearPlane, zFarPlane, dst);
403 float zNearPlane,
float zFarPlane) {
438 float zNearPlane,
float zFarPlane,
Mat4* dst);
716 memcpy(this->m, mat.m,
sizeof(
float)*16);
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);
826 #pragma mark Static Arithmetic
935 #pragma mark Arithmetic
944 return *(
add(*
this,scalar,
this));
955 return *(
add(*
this,mat,
this));
966 return *(
subtract(*
this,scalar,
this));
988 return *(
multiply(*
this,scalar,
this));
1002 return *(
multiply(*
this,mat,
this));
1011 return *(
negate(*
this,
this));
1036 return *(
invert(*
this,
this));
1086 #pragma mark Operators
1145 return result.
add(mat);
1206 #pragma mark Comparisons
1230 bool equals(
const Mat4& mat,
float variance=CU_MATH_EPSILON)
const;
1263 #pragma mark Matrix Attributes
1275 bool isIdentity(
float variance=CU_MATH_EPSILON)
const;
1299 bool isOrthogonal(
float variance=CU_MATH_EPSILON)
const;
1388 #pragma mark Static Vector Operations
1486 static float*
transform(
const Mat4& mat,
float const* input,
float* output,
size_t size);
1490 #pragma mark Vector Operations
1582 #pragma mark Static Matrix Transforms
1813 #pragma mark Matrix Transforms
1825 return *(
rotate(*
this,q,
this));
1842 return *(
rotate(*
this,axis,angle,
this));
1858 return *(
rotateX(*
this,angle,
this));
1874 return *(
rotateY(*
this,angle,
this));
1890 return *(
rotateZ(*
this,angle,
this));
1904 return *(
scale(*
this,value,
this));
1918 return *(
scale(*
this,s,
this));
1934 return *(
scale(*
this,sx,sy,sz,
this));
1964 return *(
translate(*
this,tx,ty,tz,
this));
1969 #pragma mark Conversion Methods
1980 std::string
toString(
bool verbose =
false)
const;
2028 #pragma mark Vector Operations
2042 inline Vec2& operator*=(Vec2& v,
const Mat4& m) {
2057 inline const Vec2 operator*(
const Vec2& v,
const Mat4& m) {
2058 return m.transform(v);
2072 inline Vec3& operator*=(Vec3& v,
const Mat4& m) {
2087 inline const Vec3 operator*(
const Vec3& v,
const Mat4& m) {
2088 return m.transform(v);
2102 inline Vec4& operator*=(Vec4& v,
const Mat4& m) {
2117 inline const Vec4 operator*(
const Vec4& v,
const Mat4& m) {
2118 return m.transform(v);
2129 inline const Mat4 operator*(
float scalar,
const Mat4& m) {
2131 return result.multiply(scalar);
Mat4(const Quaternion &rotation)
Definition: CUMat4.h:181
static Mat4 createOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane)
Definition: CUMat4.h:402
static Mat4 * scale(const Mat4 &mat, const Vec3 &s, Mat4 *dst)
Definition: CUMat4.h:1718
static Mat4 createRotationZ(float angle)
Definition: CUMat4.h:628
const Mat4 operator*(float scalar) const
Definition: CUMat4.h:1199
Mat4 & translate(const Vec3 &t)
Definition: CUMat4.h:1947
float getDeterminant() const
static Vec2 * transform(const Mat4 &mat, const Vec2 &point, Vec2 *dst)
static Mat4 * rotateX(const Mat4 &mat, float angle, Mat4 *dst)
Definition: CUMat4.h:1638
bool operator==(const Mat4 &mat) const
Definition: CUMat4.h:1243
const Mat4 operator*(const Mat4 &mat) const
Definition: CUMat4.h:1185
static Mat4 createRotationY(float angle)
Definition: CUMat4.h:600
static Mat4 * multiply(const Mat4 &mat, float scalar, Mat4 *dst)
bool equals(const Mat4 &mat, float variance=CU_MATH_EPSILON) const
static Mat4 createScale(const Vec3 &scale)
Definition: CUMat4.h:495
static Mat4 * rotateY(const Mat4 &mat, float angle, Mat4 *dst)
Definition: CUMat4.h:1659
Mat4 & translate(float tx, float ty, float tz)
Definition: CUMat4.h:1963
static Mat4 * scale(const Mat4 &mat, float value, Mat4 *dst)
Definition: CUMat4.h:1699
Quaternion getRotation() const
Mat4 & rotate(const Quaternion &q)
Definition: CUMat4.h:1824
Mat4 & transpose()
Definition: CUMat4.h:1063
static Mat4 * add(const Mat4 &mat, float scalar, Mat4 *dst)
const Mat4 operator-() const
Definition: CUMat4.h:1169
static const Mat4 IDENTITY
Definition: CUMat4.h:106
Mat4 & subtract(float scalar)
Definition: CUMat4.h:965
Mat4 & operator+=(const Mat4 &mat)
Definition: CUMat4.h:1094
Definition: CUAffine2.h:63
Mat4 & rotateZ(float angle)
Definition: CUMat4.h:1889
Mat4 & operator=(const Quaternion &quat)
Definition: CUMat4.h:746
Mat4 & scale(const Vec3 &s)
Definition: CUMat4.h:1917
static Mat4 createLookAt(const Vec3 &eye, const Vec3 &target, const Vec3 &up)
Definition: CUMat4.h:202
static Vec2 * transformVector(const Mat4 &mat, const Vec2 &vec, Vec2 *dst)
static Mat4 createRotationX(float angle)
Definition: CUMat4.h:572
static Mat4 * translate(const Mat4 &mat, float tx, float ty, float tz, Mat4 *dst)
Definition: CUMat4.h:1779
Mat4 & multiply(float scalar)
Definition: CUMat4.h:987
Mat4 & operator=(Mat4 &&mat)
Definition: CUMat4.h:715
Mat4 getTranspose() const
Definition: CUMat4.h:1078
Mat4 & operator=(const float *array)
Definition: CUMat4.h:735
static Mat4 createTranslation(float tx, float ty, float tz)
Definition: CUMat4.h:677
Mat4 & scale(float value)
Definition: CUMat4.h:1903
Mat4 & rotate(const Vec3 &axis, float angle)
Definition: CUMat4.h:1841
static Mat4 createTranslation(const Vec3 &trans)
Definition: CUMat4.h:653
Mat4 & add(float scalar)
Definition: CUMat4.h:943
Mat4 & operator*=(float scalar)
Definition: CUMat4.h:1130
const Mat4 operator-(const Mat4 &mat) const
Definition: CUMat4.h:1157
Mat4 & operator-=(const Mat4 &mat)
Definition: CUMat4.h:1105
static bool decompose(const Mat4 &mat, Vec3 *scale, Quaternion *rot, Vec3 *trans)
bool isOrthogonal(float variance=CU_MATH_EPSILON) const
static const Mat4 ZERO
Definition: CUMat4.h:102
Vec3 getTranslation() const
static const Mat4 ONE
Definition: CUMat4.h:104
Mat4 & multiply(const Mat4 &mat)
Definition: CUMat4.h:1001
static Mat4 * createOrthographic(float width, float height, float zNearPlane, float zFarPlane, Mat4 *dst)
Definition: CUMat4.h:367
bool isExactly(const Mat4 &mat) const
float m[16]
Definition: CUMat4.h:98
Mat4 & operator*=(const Mat4 &mat)
Definition: CUMat4.h:1119
static Mat4 createRotation(const Quaternion &quat)
Definition: CUMat4.h:517
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
static Mat4 * rotateZ(const Mat4 &mat, float angle, Mat4 *dst)
Definition: CUMat4.h:1680
Mat4 & rotateX(float angle)
Definition: CUMat4.h:1857
static Mat4 * scale(const Mat4 &mat, float sx, float sy, float sz, Mat4 *dst)
Definition: CUMat4.h:1739
static Mat4 createOrthographic(float width, float height, float zNearPlane, float zFarPlane)
Definition: CUMat4.h:334
static Mat4 createScale(float sx, float sy, float sz)
Definition: CUMat4.h:471
static Mat4 createRotation(const Vec3 &axis, float angle)
Definition: CUMat4.h:543
Vec3 getDownVector() const
static Mat4 * translate(const Mat4 &mat, const Vec3 &t, Mat4 *dst)
Definition: CUMat4.h:1758
bool isInvertible(float variance=CU_MATH_EPSILON) const
Definition: CUMat4.h:1286
Mat4 & negate()
Definition: CUMat4.h:1010
bool operator!=(const Mat4 &mat) const
Definition: CUMat4.h:1257
Mat4 & rotateY(float angle)
Definition: CUMat4.h:1873
static Mat4 * subtract(const Mat4 &mat, float scalar, Mat4 *dst)
bool isIdentity(float variance=CU_MATH_EPSILON) const
Mat4 & scale(float sx, float sy, float sz)
Definition: CUMat4.h:1933
const Mat4 operator+(const Mat4 &mat) const
Definition: CUMat4.h:1143
Mat4 & subtract(const Mat4 &mat)
Definition: CUMat4.h:976
Mat4 getInverse() const
Definition: CUMat4.h:1048
~Mat4()
Definition: CUMat4.h:188
Definition: CUQuaternion.h:97
Vec3 getLeftVector() const
static Mat4 createScale(float scale)
Definition: CUMat4.h:447
Mat4 & operator=(const Mat4 &mat)
Definition: CUMat4.h:704
Mat4 & add(const Mat4 &mat)
Definition: CUMat4.h:954
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)
static Mat4 * rotate(const Mat4 &mat, const Quaternion &quat, Mat4 *dst)
Definition: CUMat4.h:1595
Mat4 getNegation() const
Definition: CUMat4.h:1021
Vec3 getRightVector() const
Vec3 getBackVector() const
static Mat4 createPerspective(float fieldOfView, float aspectRatio, float zNearPlane, float zFarPlane)
Definition: CUMat4.h:282
Vec3 getForwardVector() const
Mat4 & invert()
Definition: CUMat4.h:1035
static Mat4 * rotate(const Mat4 &mat, const Vec3 &axis, float angle, Mat4 *dst)
Definition: CUMat4.h:1617
std::string toString(bool verbose=false) const