diff --git a/src/lol/base/types.h b/src/lol/base/types.h index 687ec775..aa44589d 100644 --- a/src/lol/base/types.h +++ b/src/lol/base/types.h @@ -38,7 +38,7 @@ int const FULL_SWIZZLE = 0xaaaa; int const NO_SWIZZLE = 0xbbbb; template struct vec; -template struct matrix; +template struct mat; template struct Cmplx; template struct Quat; @@ -68,16 +68,16 @@ LOL_VECTOR_TYPEDEFS(vec<2 COMMA, >, vec2) LOL_VECTOR_TYPEDEFS(vec<3 COMMA, >, vec3) LOL_VECTOR_TYPEDEFS(vec<4 COMMA, >, vec4) -LOL_VECTOR_TYPEDEFS(matrix<2 COMMA 2 COMMA, >, mat2) -LOL_VECTOR_TYPEDEFS(matrix<3 COMMA 3 COMMA, >, mat3) -LOL_VECTOR_TYPEDEFS(matrix<4 COMMA 4 COMMA, >, mat4) +LOL_VECTOR_TYPEDEFS(mat<2 COMMA 2 COMMA, >, mat2) +LOL_VECTOR_TYPEDEFS(mat<3 COMMA 3 COMMA, >, mat3) +LOL_VECTOR_TYPEDEFS(mat<4 COMMA 4 COMMA, >, mat4) -LOL_VECTOR_TYPEDEFS(matrix<2 COMMA 3 COMMA, >, mat2x3) -LOL_VECTOR_TYPEDEFS(matrix<2 COMMA 4 COMMA, >, mat2x4) -LOL_VECTOR_TYPEDEFS(matrix<3 COMMA 2 COMMA, >, mat3x2) -LOL_VECTOR_TYPEDEFS(matrix<3 COMMA 4 COMMA, >, mat3x4) -LOL_VECTOR_TYPEDEFS(matrix<4 COMMA 2 COMMA, >, mat4x2) -LOL_VECTOR_TYPEDEFS(matrix<4 COMMA 3 COMMA, >, mat4x3) +LOL_VECTOR_TYPEDEFS(mat<2 COMMA 3 COMMA, >, mat2x3) +LOL_VECTOR_TYPEDEFS(mat<2 COMMA 4 COMMA, >, mat2x4) +LOL_VECTOR_TYPEDEFS(mat<3 COMMA 2 COMMA, >, mat3x2) +LOL_VECTOR_TYPEDEFS(mat<3 COMMA 4 COMMA, >, mat3x4) +LOL_VECTOR_TYPEDEFS(mat<4 COMMA 2 COMMA, >, mat4x2) +LOL_VECTOR_TYPEDEFS(mat<4 COMMA 3 COMMA, >, mat4x3) LOL_VECTOR_TYPEDEFS(Cmplx<, >, cmplx) LOL_VECTOR_TYPEDEFS(Quat<, >, quat) diff --git a/src/lol/math/matrix.h b/src/lol/math/matrix.h index ff66dc2e..cc650f76 100644 --- a/src/lol/math/matrix.h +++ b/src/lol/math/matrix.h @@ -33,13 +33,13 @@ namespace lol */ template -struct matrix +struct mat { - typedef matrix type; + typedef mat type; - inline matrix() {} + inline mat() {} - explicit inline matrix(T const &val) + explicit inline mat(T const &val) { T const zero = T(0); for (int i = 0; i < COLS; ++i) @@ -59,19 +59,19 @@ private: */ template -struct matrix<2, 2, T> +struct mat<2, 2, T> { - typedef matrix<2,2,T> type; + typedef mat<2,2,T> type; - inline matrix() {} - inline matrix(vec<2,T> v0, vec<2,T> v1) + inline mat() {} + inline mat(vec<2,T> v0, vec<2,T> v1) #if LOL_FEATURE_CXX11_ARRAY_INITIALIZERS : m_data{ v0, v1 } {} #else : m_v0(v0), m_v1(v1) {} #endif - explicit inline matrix(T const &val) + explicit inline mat(T const &val) #if LOL_FEATURE_CXX11_ARRAY_INITIALIZERS : m_data{ vec<2,T>(val, T(0)), vec<2,T>(T(0), val) } {} @@ -80,7 +80,7 @@ struct matrix<2, 2, T> m_v1(T(0), val) {} #endif - explicit inline matrix(matrix<4,4,T> const &m) + explicit inline mat(mat<4,4,T> const &m) #if LOL_FEATURE_CXX11_ARRAY_INITIALIZERS : m_data{ m[0].xy, m[1].xy } {} #else @@ -96,8 +96,8 @@ struct matrix<2, 2, T> #endif /* Helpers for transformation matrices */ - static matrix<2,2,T> rotate(T degrees); - static inline matrix<2,2,T> rotate(matrix<2,2,T> m, T degrees) + static mat<2,2,T> rotate(T degrees); + static inline mat<2,2,T> rotate(mat<2,2,T> m, T degrees) { return rotate(degrees) * m; } @@ -107,9 +107,9 @@ struct matrix<2, 2, T> template friend std::ostream &operator<<(std::ostream &stream, - matrix<2,2,U> const &m); + mat<2,2,U> const &m); - static const matrix<2,2,T> identity; + static const mat<2,2,T> identity; private: #if LOL_FEATURE_CXX11_ARRAY_INITIALIZERS @@ -124,19 +124,19 @@ private: */ template -struct matrix<3,3,T> +struct mat<3,3,T> { - typedef matrix<3,3,T> type; + typedef mat<3,3,T> type; - inline matrix() {} - inline matrix(vec<3,T> v0, vec<3,T> v1, vec<3,T> v2) + inline mat() {} + inline mat(vec<3,T> v0, vec<3,T> v1, vec<3,T> v2) #if LOL_FEATURE_CXX11_ARRAY_INITIALIZERS : m_data{ v0, v1, v2 } {} #else : m_v0(v0), m_v1(v1), m_v2(v2) {} #endif - explicit inline matrix(T const &val) + explicit inline mat(T const &val) #if LOL_FEATURE_CXX11_ARRAY_INITIALIZERS : m_data{ vec<3,T>(val, (T)0, (T)0), vec<3,T>((T)0, val, (T)0), @@ -147,7 +147,7 @@ struct matrix<3,3,T> m_v2((T)0, (T)0, val) {} #endif - explicit inline matrix(matrix<2,2,T> m, T const &val = T(1)) + explicit inline mat(mat<2,2,T> m, T const &val = T(1)) #if LOL_FEATURE_CXX11_ARRAY_INITIALIZERS : m_data{ vec<3,T>(m[0], (T)0), vec<3,T>(m[1], (T)0), @@ -158,14 +158,14 @@ struct matrix<3,3,T> m_v2((T)0, (T)0, val) {} #endif - explicit inline matrix(matrix<4,4,T> const &m) + explicit inline mat(mat<4,4,T> const &m) #if LOL_FEATURE_CXX11_ARRAY_INITIALIZERS : m_data{ m[0].xyz, m[1].xyz, m[2].xyz } {} #else : m_v0(m[0].xyz), m_v1(m[1].xyz), m_v2(m[2].xyz) {} #endif - explicit matrix(Quat const &q); + explicit mat(Quat const &q); #if LOL_FEATURE_CXX11_ARRAY_INITIALIZERS inline vec<3,T>& operator[](size_t n) { return m_data[n]; } @@ -176,39 +176,39 @@ struct matrix<3,3,T> #endif /* Helpers for transformation matrices */ - static matrix<3,3,T> scale(T x); - static matrix<3,3,T> scale(T x, T y, T z); - static matrix<3,3,T> scale(vec<3,T> v); - static matrix<3,3,T> rotate(T degrees, T x, T y, T z); - static matrix<3,3,T> rotate(T degrees, vec<3,T> v); - - static matrix<3,3,T> fromeuler_xyz(vec<3,T> const &v); - static matrix<3,3,T> fromeuler_xzy(vec<3,T> const &v); - static matrix<3,3,T> fromeuler_yxz(vec<3,T> const &v); - static matrix<3,3,T> fromeuler_yzx(vec<3,T> const &v); - static matrix<3,3,T> fromeuler_zxy(vec<3,T> const &v); - static matrix<3,3,T> fromeuler_zyx(vec<3,T> const &v); - static matrix<3,3,T> fromeuler_xyz(T phi, T theta, T psi); - static matrix<3,3,T> fromeuler_xzy(T phi, T theta, T psi); - static matrix<3,3,T> fromeuler_yxz(T phi, T theta, T psi); - static matrix<3,3,T> fromeuler_yzx(T phi, T theta, T psi); - static matrix<3,3,T> fromeuler_zxy(T phi, T theta, T psi); - static matrix<3,3,T> fromeuler_zyx(T phi, T theta, T psi); - - static matrix<3,3,T> fromeuler_xyx(vec<3,T> const &v); - static matrix<3,3,T> fromeuler_xzx(vec<3,T> const &v); - static matrix<3,3,T> fromeuler_yxy(vec<3,T> const &v); - static matrix<3,3,T> fromeuler_yzy(vec<3,T> const &v); - static matrix<3,3,T> fromeuler_zxz(vec<3,T> const &v); - static matrix<3,3,T> fromeuler_zyz(vec<3,T> const &v); - static matrix<3,3,T> fromeuler_xyx(T phi, T theta, T psi); - static matrix<3,3,T> fromeuler_xzx(T phi, T theta, T psi); - static matrix<3,3,T> fromeuler_yxy(T phi, T theta, T psi); - static matrix<3,3,T> fromeuler_yzy(T phi, T theta, T psi); - static matrix<3,3,T> fromeuler_zxz(T phi, T theta, T psi); - static matrix<3,3,T> fromeuler_zyz(T phi, T theta, T psi); - - static inline matrix<3,3,T> rotate(matrix<3,3,T> m, T degrees, vec<3,T> v) + static mat<3,3,T> scale(T x); + static mat<3,3,T> scale(T x, T y, T z); + static mat<3,3,T> scale(vec<3,T> v); + static mat<3,3,T> rotate(T degrees, T x, T y, T z); + static mat<3,3,T> rotate(T degrees, vec<3,T> v); + + static mat<3,3,T> fromeuler_xyz(vec<3,T> const &v); + static mat<3,3,T> fromeuler_xzy(vec<3,T> const &v); + static mat<3,3,T> fromeuler_yxz(vec<3,T> const &v); + static mat<3,3,T> fromeuler_yzx(vec<3,T> const &v); + static mat<3,3,T> fromeuler_zxy(vec<3,T> const &v); + static mat<3,3,T> fromeuler_zyx(vec<3,T> const &v); + static mat<3,3,T> fromeuler_xyz(T phi, T theta, T psi); + static mat<3,3,T> fromeuler_xzy(T phi, T theta, T psi); + static mat<3,3,T> fromeuler_yxz(T phi, T theta, T psi); + static mat<3,3,T> fromeuler_yzx(T phi, T theta, T psi); + static mat<3,3,T> fromeuler_zxy(T phi, T theta, T psi); + static mat<3,3,T> fromeuler_zyx(T phi, T theta, T psi); + + static mat<3,3,T> fromeuler_xyx(vec<3,T> const &v); + static mat<3,3,T> fromeuler_xzx(vec<3,T> const &v); + static mat<3,3,T> fromeuler_yxy(vec<3,T> const &v); + static mat<3,3,T> fromeuler_yzy(vec<3,T> const &v); + static mat<3,3,T> fromeuler_zxz(vec<3,T> const &v); + static mat<3,3,T> fromeuler_zyz(vec<3,T> const &v); + static mat<3,3,T> fromeuler_xyx(T phi, T theta, T psi); + static mat<3,3,T> fromeuler_xzx(T phi, T theta, T psi); + static mat<3,3,T> fromeuler_yxy(T phi, T theta, T psi); + static mat<3,3,T> fromeuler_yzy(T phi, T theta, T psi); + static mat<3,3,T> fromeuler_zxz(T phi, T theta, T psi); + static mat<3,3,T> fromeuler_zyz(T phi, T theta, T psi); + + static inline mat<3,3,T> rotate(mat<3,3,T> m, T degrees, vec<3,T> v) { return rotate(degrees, v) * m; } @@ -218,9 +218,9 @@ struct matrix<3,3,T> template friend std::ostream &operator<<(std::ostream &stream, - matrix<3,3,U> const &m); + mat<3,3,U> const &m); - static const matrix<3,3,T> identity; + static const mat<3,3,T> identity; private: #if LOL_FEATURE_CXX11_ARRAY_INITIALIZERS @@ -235,19 +235,19 @@ private: */ template -struct matrix<4, 4, T> +struct mat<4, 4, T> { - typedef matrix<4,4,T> type; + typedef mat<4,4,T> type; - inline matrix() {} - inline matrix(vec<4,T> v0, vec<4,T> v1, vec<4,T> v2, vec<4,T> v3) + inline mat() {} + inline mat(vec<4,T> v0, vec<4,T> v1, vec<4,T> v2, vec<4,T> v3) #if LOL_FEATURE_CXX11_ARRAY_INITIALIZERS : m_data{ v0, v1, v2, v3 } {} #else : m_v0(v0), m_v1(v1), m_v2(v2), m_v3(v3) {} #endif - explicit inline matrix(T const &val) + explicit inline mat(T const &val) #if LOL_FEATURE_CXX11_ARRAY_INITIALIZERS : m_data{ vec<4,T>(val, (T)0, (T)0, (T)0), vec<4,T>((T)0, val, (T)0, (T)0), @@ -260,7 +260,7 @@ struct matrix<4, 4, T> m_v3((T)0, (T)0, (T)0, val) {} #endif - explicit inline matrix(matrix<2,2,T> m, T const &val = T(1)) + explicit inline mat(mat<2,2,T> m, T const &val = T(1)) #if LOL_FEATURE_CXX11_ARRAY_INITIALIZERS : m_data{ vec<4,T>(m[0], (T)0, (T)0), vec<4,T>(m[1], (T)0, (T)0), @@ -273,7 +273,7 @@ struct matrix<4, 4, T> m_v3((T)0, (T)0, (T)0, val) {} #endif - explicit inline matrix(matrix<3,3,T> m, T const &val = T(1)) + explicit inline mat(mat<3,3,T> m, T const &val = T(1)) #if LOL_FEATURE_CXX11_ARRAY_INITIALIZERS : m_data{ vec<4,T>(m[0], (T)0), vec<4,T>(m[1], (T)0), @@ -286,7 +286,7 @@ struct matrix<4, 4, T> m_v3((T)0, (T)0, (T)0, val) {} #endif - explicit matrix(Quat const &q); + explicit mat(Quat const &q); #if LOL_FEATURE_CXX11_ARRAY_INITIALIZERS inline vec<4,T>& operator[](size_t n) { return m_data[n]; } @@ -297,88 +297,88 @@ struct matrix<4, 4, T> #endif /* Helpers for transformation matrices */ - static matrix<4,4,T> translate(T x, T y, T z); - static matrix<4,4,T> translate(vec<3,T> v); + static mat<4,4,T> translate(T x, T y, T z); + static mat<4,4,T> translate(vec<3,T> v); - static inline matrix<4,4,T> scale(T x) + static inline mat<4,4,T> scale(T x) { - return matrix<4,4,T>(matrix<3,3,T>::scale(x), (T)1); + return mat<4,4,T>(mat<3,3,T>::scale(x), (T)1); } - static inline matrix<4,4,T> scale(T x, T y, T z) + static inline mat<4,4,T> scale(T x, T y, T z) { - return matrix<4,4,T>(matrix<3,3,T>::scale(x, y, z), (T)1); + return mat<4,4,T>(mat<3,3,T>::scale(x, y, z), (T)1); } - static inline matrix<4,4,T> scale(vec<3,T> v) + static inline mat<4,4,T> scale(vec<3,T> v) { - return matrix<4,4,T>(matrix<3,3,T>::scale(v), (T)1); + return mat<4,4,T>(mat<3,3,T>::scale(v), (T)1); } - static inline matrix<4,4,T> translate(matrix<4,4,T> const &m, vec<3,T> v) + static inline mat<4,4,T> translate(mat<4,4,T> const &m, vec<3,T> v) { return translate(v) * m; } - static inline matrix<4,4,T> rotate(T degrees, T x, T y, T z) + static inline mat<4,4,T> rotate(T degrees, T x, T y, T z) { - return matrix<4,4,T>(matrix<3,3,T>::rotate(degrees, x, y, z), (T)1); + return mat<4,4,T>(mat<3,3,T>::rotate(degrees, x, y, z), (T)1); } - static inline matrix<4,4,T> rotate(T degrees, vec<3,T> v) + static inline mat<4,4,T> rotate(T degrees, vec<3,T> v) { - return matrix<4,4,T>(matrix<3,3,T>::rotate(degrees, v), (T)1); + return mat<4,4,T>(mat<3,3,T>::rotate(degrees, v), (T)1); } - static inline matrix<4,4,T> rotate(matrix<4,4,T> &m, T degrees, vec<3,T> v) + static inline mat<4,4,T> rotate(mat<4,4,T> &m, T degrees, vec<3,T> v) { return rotate(degrees, v) * m; } - static matrix<4,4,T> fromeuler_xyz(vec<3,T> const &v); - static matrix<4,4,T> fromeuler_xzy(vec<3,T> const &v); - static matrix<4,4,T> fromeuler_yxz(vec<3,T> const &v); - static matrix<4,4,T> fromeuler_yzx(vec<3,T> const &v); - static matrix<4,4,T> fromeuler_zxy(vec<3,T> const &v); - static matrix<4,4,T> fromeuler_zyx(vec<3,T> const &v); - static matrix<4,4,T> fromeuler_xyz(T phi, T theta, T psi); - static matrix<4,4,T> fromeuler_xzy(T phi, T theta, T psi); - static matrix<4,4,T> fromeuler_yxz(T phi, T theta, T psi); - static matrix<4,4,T> fromeuler_yzx(T phi, T theta, T psi); - static matrix<4,4,T> fromeuler_zxy(T phi, T theta, T psi); - static matrix<4,4,T> fromeuler_zyx(T phi, T theta, T psi); - - static matrix<4,4,T> fromeuler_xyx(vec<3,T> const &v); - static matrix<4,4,T> fromeuler_xzx(vec<3,T> const &v); - static matrix<4,4,T> fromeuler_yxy(vec<3,T> const &v); - static matrix<4,4,T> fromeuler_yzy(vec<3,T> const &v); - static matrix<4,4,T> fromeuler_zxz(vec<3,T> const &v); - static matrix<4,4,T> fromeuler_zyz(vec<3,T> const &v); - static matrix<4,4,T> fromeuler_xyx(T phi, T theta, T psi); - static matrix<4,4,T> fromeuler_xzx(T phi, T theta, T psi); - static matrix<4,4,T> fromeuler_yxy(T phi, T theta, T psi); - static matrix<4,4,T> fromeuler_yzy(T phi, T theta, T psi); - static matrix<4,4,T> fromeuler_zxz(T phi, T theta, T psi); - static matrix<4,4,T> fromeuler_zyz(T phi, T theta, T psi); + static mat<4,4,T> fromeuler_xyz(vec<3,T> const &v); + static mat<4,4,T> fromeuler_xzy(vec<3,T> const &v); + static mat<4,4,T> fromeuler_yxz(vec<3,T> const &v); + static mat<4,4,T> fromeuler_yzx(vec<3,T> const &v); + static mat<4,4,T> fromeuler_zxy(vec<3,T> const &v); + static mat<4,4,T> fromeuler_zyx(vec<3,T> const &v); + static mat<4,4,T> fromeuler_xyz(T phi, T theta, T psi); + static mat<4,4,T> fromeuler_xzy(T phi, T theta, T psi); + static mat<4,4,T> fromeuler_yxz(T phi, T theta, T psi); + static mat<4,4,T> fromeuler_yzx(T phi, T theta, T psi); + static mat<4,4,T> fromeuler_zxy(T phi, T theta, T psi); + static mat<4,4,T> fromeuler_zyx(T phi, T theta, T psi); + + static mat<4,4,T> fromeuler_xyx(vec<3,T> const &v); + static mat<4,4,T> fromeuler_xzx(vec<3,T> const &v); + static mat<4,4,T> fromeuler_yxy(vec<3,T> const &v); + static mat<4,4,T> fromeuler_yzy(vec<3,T> const &v); + static mat<4,4,T> fromeuler_zxz(vec<3,T> const &v); + static mat<4,4,T> fromeuler_zyz(vec<3,T> const &v); + static mat<4,4,T> fromeuler_xyx(T phi, T theta, T psi); + static mat<4,4,T> fromeuler_xzx(T phi, T theta, T psi); + static mat<4,4,T> fromeuler_yxy(T phi, T theta, T psi); + static mat<4,4,T> fromeuler_yzy(T phi, T theta, T psi); + static mat<4,4,T> fromeuler_zxz(T phi, T theta, T psi); + static mat<4,4,T> fromeuler_zyz(T phi, T theta, T psi); /* Helpers for view matrices */ - static matrix<4,4,T> lookat(vec<3,T> eye, vec<3,T> center, vec<3,T> up); + static mat<4,4,T> lookat(vec<3,T> eye, vec<3,T> center, vec<3,T> up); /* Helpers for projection matrices */ - static matrix<4,4,T> ortho(T left, T right, T bottom, T top, T near, T far); - static matrix<4,4,T> ortho(T width, T height, T near, T far); - static matrix<4,4,T> frustum(T left, T right, T bottom, T top, T near, T far); - static matrix<4,4,T> perspective(T fov_y, T width, T height, T near, T far); - static matrix<4,4,T> shifted_perspective(T fov_y, T screen_size, T screen_ratio_yx, T near, T far); + static mat<4,4,T> ortho(T left, T right, T bottom, T top, T near, T far); + static mat<4,4,T> ortho(T width, T height, T near, T far); + static mat<4,4,T> frustum(T left, T right, T bottom, T top, T near, T far); + static mat<4,4,T> perspective(T fov_y, T width, T height, T near, T far); + static mat<4,4,T> shifted_perspective(T fov_y, T screen_size, T screen_ratio_yx, T near, T far); void printf() const; String tostring() const; template friend std::ostream &operator<<(std::ostream &stream, - matrix<4,4,U> const &m); + mat<4,4,U> const &m); - static const matrix<4,4,T> identity; + static const mat<4,4,T> identity; private: #if LOL_FEATURE_CXX11_ARRAY_INITIALIZERS @@ -388,18 +388,18 @@ private: #endif }; -template T determinant(matrix<2,2,T> const &); -template T determinant(matrix<3,3,T> const &); -template T determinant(matrix<4,4,T> const &); +template T determinant(mat<2,2,T> const &); +template T determinant(mat<3,3,T> const &); +template T determinant(mat<4,4,T> const &); -template matrix<2,2,T> inverse(matrix<2,2,T> const &); -template matrix<3,3,T> inverse(matrix<3,3,T> const &); -template matrix<4,4,T> inverse(matrix<4,4,T> const &); +template mat<2,2,T> inverse(mat<2,2,T> const &); +template mat<3,3,T> inverse(mat<3,3,T> const &); +template mat<4,4,T> inverse(mat<4,4,T> const &); template -static inline matrix transpose(matrix const &m) +static inline mat transpose(mat const &m) { - matrix ret; + mat ret; for (int i = 0; i < COLS; ++i) for (int j = 0; j < ROWS; ++j) ret[j][i] = m[i][j]; @@ -411,8 +411,8 @@ static inline matrix transpose(matrix const &m) */ template -static inline matrix &operator +=(matrix &a, - matrix const &b) +static inline mat &operator +=(mat &a, + mat const &b) { for (int i = 0; i < COLS; ++i) a[i] += b[i]; @@ -420,22 +420,22 @@ static inline matrix &operator +=(matrix &a, } template -static inline matrix operator +(matrix const &a, - matrix const &b) +static inline mat operator +(mat const &a, + mat const &b) { - matrix ret = a; + mat ret = a; return ret += b; } template -static inline matrix operator +(matrix const &m) +static inline mat operator +(mat const &m) { return m; } template -static inline matrix &operator -=(matrix &a, - matrix const &b) +static inline mat &operator -=(mat &a, + mat const &b) { for (int i = 0; i < COLS; ++i) a[i] -= b[i]; @@ -443,17 +443,17 @@ static inline matrix &operator -=(matrix &a, } template -static inline matrix operator -(matrix const &a, - matrix const &b) +static inline mat operator -(mat const &a, + mat const &b) { - matrix ret = a; + mat ret = a; return ret -= b; } template -static inline matrix operator -(matrix const &m) +static inline mat operator -(mat const &m) { - matrix ret; + mat ret; for (int i = 0; i < COLS; ++i) ret[i] = -m[i]; return ret; @@ -464,7 +464,7 @@ static inline matrix operator -(matrix const &m) */ template -static inline vec operator *(matrix const &m, +static inline vec operator *(mat const &m, vec const &v) { vec ret(T(0)); @@ -475,7 +475,7 @@ static inline vec operator *(matrix const &m, template static inline vec operator *(vec const &v, - matrix const &m) + mat const &m) { vec ret(T(0)); for (int i = 0; i < COLS; ++i) @@ -488,18 +488,18 @@ static inline vec operator *(vec const &v, */ template -static inline matrix operator *(matrix const &a, - matrix const &b) +static inline mat operator *(mat const &a, + mat const &b) { - matrix ret; + mat ret; for (int i = 0; i < COLS; ++i) ret[i] = a * b[i]; return ret; } template -static inline matrix &operator *=(matrix &a, - matrix const &b) +static inline mat &operator *=(mat &a, + mat const &b) { return a = a * b; } diff --git a/src/lol/math/transform.h b/src/lol/math/transform.h index a275fcd4..45136ef9 100644 --- a/src/lol/math/transform.h +++ b/src/lol/math/transform.h @@ -155,8 +155,8 @@ template struct Quat explicit inline constexpr Quat(Quat const &q) : w(q.w), x(q.x), y(q.y), z(q.z) {} - Quat(matrix<3,3,T> const &m); - Quat(matrix<4,4,T> const &m); + Quat(mat<3,3,T> const &m); + Quat(mat<4,4,T> const &m); LOL_COMMON_MEMBER_OPS(w) LOL_NONVECTOR_MEMBER_OPS() diff --git a/src/math/constants.cpp b/src/math/constants.cpp index 47caebeb..9b07fcf6 100644 --- a/src/math/constants.cpp +++ b/src/math/constants.cpp @@ -30,13 +30,13 @@ namespace lol { #define LOL_MAT_CONST(type, name, a) \ template<> \ - matrix<2,2,type> const matrix<2,2,type>::name = matrix<2,2,type>((type)a); \ + mat<2,2,type> const mat<2,2,type>::name = mat<2,2,type>((type)a); \ \ template<> \ - matrix<3,3,type> const matrix<3,3,type>::name = matrix<3,3,type>((type)a); \ + mat<3,3,type> const mat<3,3,type>::name = mat<3,3,type>((type)a); \ \ template<> \ - matrix<4,4,type> const matrix<4,4,type>::name = matrix<4,4,type>((type)a); + mat<4,4,type> const mat<4,4,type>::name = mat<4,4,type>((type)a); #define LOL_ALL_CONST_INNER(type) \ LOL_VEC_2_CONST(type, zero, 0, 0) \ diff --git a/src/math/vector.cpp b/src/math/vector.cpp index 61f1f56c..1cb71ba4 100644 --- a/src/math/vector.cpp +++ b/src/math/vector.cpp @@ -378,7 +378,7 @@ template<> mat3 mat3::rotate(float degrees, vec3 v) return rotate(degrees, v.x, v.y, v.z); } -template<> mat3::matrix(quat const &q) +template<> mat3::mat(quat const &q) { float n = norm(q); @@ -405,7 +405,7 @@ template<> mat3::matrix(quat const &q) (*this)[2][2] = 1.0f - s * (q.x * q.x + q.y * q.y); } -template<> mat4::matrix(quat const &q) +template<> mat4::mat(quat const &q) { *this = mat4(mat3(q), 1.f); }