From 0ea995d32f225ef9b512742d1cfed358d808ed9b Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Sat, 27 Feb 2021 05:48:23 +0700 Subject: [PATCH] ext returns minimal matrices for rotate and scale --- README.md | 62 ++++--- headers/vmath.hpp/vmath_ext.hpp | 310 ++++++++++++++++---------------- untests/vmath_fix_tests.cpp | 59 +++--- untests/vmath_mat_fun_tests.cpp | 2 +- 4 files changed, 226 insertions(+), 207 deletions(-) diff --git a/README.md b/README.md index 7a15b6d..3ee391b 100644 --- a/README.md +++ b/README.md @@ -1812,50 +1812,56 @@ template < typename T > mat translate(const mat& m, const vec& v); template < typename T > -mat rotate(const qua& q); +mat rotate(const qua& q); template < typename T > -mat rotate(const mat& m, const qua& q); +mat rotate(const mat& m, const qua& q); template < typename T > -mat rotate(T angle, const vec& axis); +mat rotate(T angle, const vec& axis); template < typename T > -mat rotate(const mat& m, T angle, const vec& axis); +mat rotate(const mat& m, T angle, const vec& axis); template < typename T > -mat rotate_x(T angle); +mat rotate_x(T angle); template < typename T > -mat rotate_x(const mat& m, T angle); +mat rotate_x(const mat& m, T angle); template < typename T > -mat rotate_y(T angle); +mat rotate_y(T angle); template < typename T > -mat rotate_y(const mat& m, T angle); +mat rotate_y(const mat& m, T angle); template < typename T > -mat rotate_z(T angle); +mat rotate_z(T angle); template < typename T > -mat rotate_z(const mat& m, T angle); +mat rotate_z(const mat& m, T angle); template < typename T > -mat scale(T x, T y, T z); +mat scale(T x, T y, T z); template < typename T > -mat scale(const mat& m, T x, T y, T z); +mat scale(const mat& m, T x, T y, T z); template < typename T > -mat scale(const vec& v); +mat scale(const vec& v); template < typename T > -mat scale(const mat& m, const vec& v); +mat scale(const mat& m, const vec& v); + +template < typename T > +mat look_at_lh(const vec& dir, const vec& up); template < typename T > mat look_at_lh(const vec& eye, const vec& at, const vec& up); +template < typename T > +mat look_at_rh(const vec& dir, const vec& up); + template < typename T > mat look_at_rh(const vec& eye, const vec& at, const vec& up); ``` @@ -1876,46 +1882,46 @@ template < typename T > mat translate(const mat& m, const vec& v); template < typename T > -mat rotate(T angle); +mat rotate(T angle); template < typename T > -mat rotate(const mat& m, T angle); +mat rotate(const mat& m, T angle); template < typename T > -mat scale(T x, T y); +mat scale(T x, T y); template < typename T > -mat scale(const mat& m, T x, T y); +mat scale(const mat& m, T x, T y); template < typename T > -mat scale(const vec& v); +mat scale(const vec& v); template < typename T > -mat scale(const mat& m, const vec& v); +mat scale(const mat& m, const vec& v); template < typename T > -mat shear(T x, T y); +mat shear(T x, T y); template < typename T > -mat shear(const mat& m, T x, T y); +mat shear(const mat& m, T x, T y); template < typename T > -mat shear(const vec& v); +mat shear(const vec& v); template < typename T > -mat shear(const mat& m, const vec& v); +mat shear(const mat& m, const vec& v); template < typename T > -mat shear_x(T y); +mat shear_x(T y); template < typename T > -mat shear_x(const mat& m, T y); +mat shear_x(const mat& m, T y); template < typename T > -mat shear_y(T x); +mat shear_y(T x); template < typename T > -mat shear_y(const mat& m, T x); +mat shear_y(const mat& m, T x); ``` ### Matrix Projections diff --git a/headers/vmath.hpp/vmath_ext.hpp b/headers/vmath.hpp/vmath_ext.hpp index a777fa6..47f42d2 100644 --- a/headers/vmath.hpp/vmath_ext.hpp +++ b/headers/vmath.hpp/vmath_ext.hpp @@ -238,10 +238,10 @@ namespace vmath_hpp /// https://en.wikipedia.org/wiki/Translation_(geometry) return { - {T{1}, T{0}, T{0}, T{0}}, - {T{0}, T{1}, T{0}, T{0}}, - {T{0}, T{0}, T{1}, T{0}}, - { x, y, z, T{1}}}; + { T{1}, T{0}, T{0}, T{0} }, + { T{0}, T{1}, T{0}, T{0} }, + { T{0}, T{0}, T{1}, T{0} }, + { x, y, z, T{1} }}; } template < typename T > @@ -262,7 +262,7 @@ namespace vmath_hpp // rotate template < typename T > - [[nodiscard]] constexpr mat rotate(const qua& q) { + [[nodiscard]] constexpr mat rotate(const qua& q) { /// REFERENCE: /// http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToMatrix/ @@ -285,19 +285,18 @@ namespace vmath_hpp const T zz2 = qv.z * z2; return { - T{1} - (yy2 + zz2), (xy2 + sz2), (xz2 - sy2), T{0}, - (xy2 - sz2), T{1} - (xx2 + zz2), (yz2 + sx2), T{0}, - (xz2 + sy2), (yz2 - sx2), T{1} - (xx2 + yy2), T{0}, - T{0}, T{0}, T{0}, T{1}}; + { T{1} - (yy2 + zz2), (xy2 + sz2), (xz2 - sy2) }, + { (xy2 - sz2), T{1} - (xx2 + zz2), (yz2 + sx2) }, + { (xz2 + sy2), (yz2 - sx2), T{1} - (xx2 + yy2) }}; } template < typename T > - [[nodiscard]] constexpr mat rotate(const mat& m, const qua& q) { + [[nodiscard]] constexpr mat rotate(const mat& m, const qua& q) { return m * rotate(q); } template < typename T > - [[nodiscard]] constexpr mat rotate(T angle, const vec& axis) { + [[nodiscard]] constexpr mat rotate(T angle, const vec& axis) { /// REFERENCE: /// http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToMatrix/ @@ -323,107 +322,124 @@ namespace vmath_hpp const T yzm = y * z * ic; return { - xxm + c, xym + zs, xzm - ys, T{0}, - xym - zs, yym + c, yzm + xs, T{0}, - xzm + ys, yzm - xs, zzm + c, T{0}, - T{0}, T{0}, T{0}, T{1}}; + { xxm + c, xym + zs, xzm - ys }, + { xym - zs, yym + c, yzm + xs }, + { xzm + ys, yzm - xs, zzm + c }}; } template < typename T > - [[nodiscard]] constexpr mat rotate(const mat& m, T angle, const vec& axis) { + [[nodiscard]] constexpr mat rotate(const mat& m, T angle, const vec& axis) { return m * rotate(angle, axis); } template < typename T > - [[nodiscard]] constexpr mat rotate_x(T angle) { + [[nodiscard]] constexpr mat rotate_x(T angle) { /// REFERENCE: /// http://www.euclideanspace.com/maths/algebra/matrix/orthogonal/rotation/ const auto [s, c] = sincos(angle); return { - T{1}, T{0}, T{0}, T{0}, - T{0}, c, s, T{0}, - T{0}, -s, c, T{0}, - T{0}, T{0}, T{0}, T{1}}; + { T{1}, T{0}, T{0} }, + { T{0}, c, s }, + { T{0}, -s, c }}; } template < typename T > - [[nodiscard]] constexpr mat rotate_x(const mat& m, T angle) { + [[nodiscard]] constexpr mat rotate_x(const mat& m, T angle) { return m * rotate_x(angle); } template < typename T > - [[nodiscard]] constexpr mat rotate_y(T angle) { + [[nodiscard]] constexpr mat rotate_y(T angle) { /// REFERENCE: /// http://www.euclideanspace.com/maths/algebra/matrix/orthogonal/rotation/ const auto [s, c] = sincos(angle); return { - c, T{0}, -s, T{0}, - T{0}, T{1}, T{0}, T{0}, - s, T{0}, c, T{0}, - T{0}, T{0}, T{0}, T{1}}; + { c, T{0}, -s }, + { T{0}, T{1}, T{0} }, + { s, T{0}, c }}; } template < typename T > - [[nodiscard]] constexpr mat rotate_y(const mat& m, T angle) { + [[nodiscard]] constexpr mat rotate_y(const mat& m, T angle) { return m * rotate_y(angle); } template < typename T > - [[nodiscard]] constexpr mat rotate_z(T angle) { + [[nodiscard]] constexpr mat rotate_z(T angle) { /// REFERENCE: /// http://www.euclideanspace.com/maths/algebra/matrix/orthogonal/rotation/ const auto [s, c] = sincos(angle); return { - c, s, T{0}, T{0}, - -s, c, T{0}, T{0}, - T{0}, T{0}, T{1}, T{0}, - T{0}, T{0}, T{0}, T{1}}; + { c, s, T{0} }, + { -s, c, T{0} }, + { T{0}, T{0}, T{1} }}; } template < typename T > - [[nodiscard]] constexpr mat rotate_z(const mat& m, T angle) { + [[nodiscard]] constexpr mat rotate_z(const mat& m, T angle) { return m * rotate_z(angle); } // scale template < typename T > - [[nodiscard]] constexpr mat scale(T x, T y, T z) { + [[nodiscard]] constexpr mat scale(T x, T y, T z) { /// REFERENCE: /// https://en.wikipedia.org/wiki/Scaling_(geometry) return { - { x, T{0}, T{0}, T{0}}, - {T{0}, y, T{0}, T{0}}, - {T{0}, T{0}, z, T{0}}, - {T{0}, T{0}, T{0}, T{1}}}; + { x, T{0}, T{0} }, + { T{0}, y, T{0} }, + { T{0}, T{0}, z }}; } template < typename T > - [[nodiscard]] constexpr mat scale(const mat& m, T x, T y, T z) { + [[nodiscard]] constexpr mat scale(const mat& m, T x, T y, T z) { return m * scale(x, y, z); } template < typename T > - [[nodiscard]] constexpr mat scale(const vec& v) { + [[nodiscard]] constexpr mat scale(const vec& v) { return scale(v.x, v.y, v.z); } template < typename T > - [[nodiscard]] constexpr mat scale(const mat& m, const vec& v) { + [[nodiscard]] constexpr mat scale(const mat& m, const vec& v) { return m * scale(v); } // look_at template < typename T > - [[nodiscard]] constexpr mat look_at_lh(const vec& eye, const vec& at, const vec& up) { + [[nodiscard]] constexpr mat look_at_lh( + const vec& dir, + const vec& up) + { + /// REFERENCE: + /// https://www.euclideanspace.com/maths/algebra/vectors/lookat/ + + const vec az = normalize(dir); + const vec ax = normalize(cross(up, az)); + const vec ay = cross(az, ax); + + return { + { ax.x, ay.x, az.x }, + { ax.y, ay.y, az.y }, + { ax.z, ay.z, az.z }}; + } + + template < typename T > + [[nodiscard]] constexpr mat look_at_lh( + const vec& eye, + const vec& at, + const vec& up) + { /// REFERENCE: /// https://www.euclideanspace.com/maths/algebra/vectors/lookat/ @@ -436,14 +452,36 @@ namespace vmath_hpp const T dz = dot(az, eye); return { - ax.x, ay.x, az.x, T{0}, - ax.y, ay.y, az.y, T{0}, - ax.z, ay.z, az.z, T{0}, - -dx, -dy, -dz, T{1}}; + { ax.x, ay.x, az.x, T{0} }, + { ax.y, ay.y, az.y, T{0} }, + { ax.z, ay.z, az.z, T{0} }, + { -dx, -dy, -dz, T{1} }}; } template < typename T > - [[nodiscard]] constexpr mat look_at_rh(const vec& eye, const vec& at, const vec& up) { + [[nodiscard]] constexpr mat look_at_rh( + const vec& dir, + const vec& up) + { + /// REFERENCE: + /// https://www.euclideanspace.com/maths/algebra/vectors/lookat/ + + const vec az = normalize(-dir); + const vec ax = normalize(cross(up, az)); + const vec ay = cross(az, ax); + + return { + { ax.x, ay.x, az.x }, + { ax.y, ay.y, az.y }, + { ax.z, ay.z, az.z }}; + } + + template < typename T > + [[nodiscard]] constexpr mat look_at_rh( + const vec& eye, + const vec& at, + const vec& up) + { /// REFERENCE: /// https://www.euclideanspace.com/maths/algebra/vectors/lookat/ @@ -456,10 +494,10 @@ namespace vmath_hpp const T dz = dot(az, eye); return { - ax.x, ay.x, az.x, T{0}, - ax.y, ay.y, az.y, T{0}, - ax.z, ay.z, az.z, T{0}, - -dx, -dy, -dz, T{1}}; + { ax.x, ay.x, az.x, T{0} }, + { ax.y, ay.y, az.y, T{0} }, + { ax.z, ay.z, az.z, T{0} }, + { -dx, -dy, -dz, T{1} }}; } } @@ -477,9 +515,9 @@ namespace vmath_hpp /// https://en.wikipedia.org/wiki/Translation_(geometry) return { - {T{1}, T{0}, T{0}}, - {T{0}, T{1}, T{0}}, - { x, y, T{1}}}; + { T{1}, T{0}, T{0} }, + { T{0}, T{1}, T{0} }, + { x, y, T{1} }}; } template < typename T > @@ -500,108 +538,103 @@ namespace vmath_hpp // rotate template < typename T > - [[nodiscard]] constexpr mat rotate(T angle) { + [[nodiscard]] constexpr mat rotate(T angle) { /// REFERENCE: /// http://www.euclideanspace.com/maths/algebra/matrix/orthogonal/rotation/ const auto [s, c] = sincos(angle); return { - c, s, T{0}, - -s, c, T{0}, - T{0}, T{0}, T{1}}; + { c, s }, + { -s, c }}; } template < typename T > - [[nodiscard]] constexpr mat rotate(const mat& m, T angle) { + [[nodiscard]] constexpr mat rotate(const mat& m, T angle) { return m * rotate(angle); } // scale template < typename T > - [[nodiscard]] constexpr mat scale(T x, T y) { + [[nodiscard]] constexpr mat scale(T x, T y) { /// REFERENCE: /// https://en.wikipedia.org/wiki/Scaling_(geometry) return { - { x, T{0}, T{0}}, - {T{0}, y, T{0}}, - {T{0}, T{0}, T{1}}}; + { x, T{0} }, + { T{0}, y }}; } template < typename T > - [[nodiscard]] constexpr mat scale(const mat& m, T x, T y) { + [[nodiscard]] constexpr mat scale(const mat& m, T x, T y) { return m * scale(x, y); } template < typename T > - [[nodiscard]] constexpr mat scale(const vec& v) { + [[nodiscard]] constexpr mat scale(const vec& v) { return scale(v.x, v.y); } template < typename T > - [[nodiscard]] constexpr mat scale(const mat& m, const vec& v) { + [[nodiscard]] constexpr mat scale(const mat& m, const vec& v) { return m * scale(v); } // shear template < typename T > - [[nodiscard]] constexpr mat shear(T x, T y) { + [[nodiscard]] constexpr mat shear(T x, T y) { /// REFERENCE: /// https://en.wikipedia.org/wiki/Shear_matrix return { - {T{1}, y, T{0}}, - { x, T{1}, T{0}}, - {T{0}, T{0}, T{1}}}; + { T{1}, y }, + { x, T{1} }}; } template < typename T > - [[nodiscard]] constexpr mat shear(const mat& m, T x, T y) { + [[nodiscard]] constexpr mat shear(const mat& m, T x, T y) { return m * shear(x, y); } template < typename T > - [[nodiscard]] constexpr mat shear(const vec& v) { + [[nodiscard]] constexpr mat shear(const vec& v) { return shear(v.x, v.y); } template < typename T > - [[nodiscard]] constexpr mat shear(const mat& m, const vec& v) { + [[nodiscard]] constexpr mat shear(const mat& m, const vec& v) { return m * shear(v); } template < typename T > - [[nodiscard]] constexpr mat shear_x(T x) { + [[nodiscard]] constexpr mat shear_x(T x) { /// REFERENCE: /// https://en.wikipedia.org/wiki/Shear_matrix return { - {T{1}, T{0}, T{0}}, - { x, T{1}, T{0}}, - {T{0}, T{0}, T{1}}}; + { T{1}, T{0} }, + { x, T{1} }}; } template < typename T > - [[nodiscard]] constexpr mat shear_x(const mat& m, T x) { + [[nodiscard]] constexpr mat shear_x(const mat& m, T x) { return m * shear_x(x); } template < typename T > - [[nodiscard]] constexpr mat shear_y(T y) { + [[nodiscard]] constexpr mat shear_y(T y) { /// REFERENCE: /// https://en.wikipedia.org/wiki/Shear_matrix return { - {T{1}, y, T{0}}, - {T{0}, T{1}, T{0}}, - {T{0}, T{0}, T{1}}}; + { T{1}, y }, + { T{0}, T{1} }}; } template < typename T > - [[nodiscard]] constexpr mat shear_y(const mat& m, T y) { + [[nodiscard]] constexpr mat shear_y(const mat& m, T y) { return m * shear_y(y); } } @@ -629,10 +662,10 @@ namespace vmath_hpp const T tz = -frange * znear; return { - sx, T{0}, T{0}, T{0}, - T{0}, sy, T{0}, T{0}, - T{0}, T{0}, sz, T{0}, - T{0}, T{0}, tz, T{1}}; + { sx, T{0}, T{0}, T{0} }, + { T{0}, sy, T{0}, T{0} }, + { T{0}, T{0}, sz, T{0} }, + { T{0}, T{0}, tz, T{1} }}; } template < typename T > @@ -650,10 +683,10 @@ namespace vmath_hpp const T tz = frange * znear; return { - sx, T{0}, T{0}, T{0}, - T{0}, sy, T{0}, T{0}, - T{0}, T{0}, sz, T{0}, - T{0}, T{0}, tz, T{1}}; + { sx, T{0}, T{0}, T{0} }, + { T{0}, sy, T{0}, T{0} }, + { T{0}, T{0}, sz, T{0} }, + { T{0}, T{0}, tz, T{1} }}; } template < typename T > @@ -666,10 +699,10 @@ namespace vmath_hpp const T frange = rcp(zfar - znear); return { - T{2} * rwidth, T{0}, T{0}, T{0}, - T{0}, T{2} * rheight, T{0}, T{0}, - T{0}, T{0}, frange, T{0}, - -(left + right) * rwidth, -(top + bottom) * rheight, -frange * znear, T{1}}; + { T{2} * rwidth, T{0}, T{0}, T{0} }, + { T{0}, T{2} * rheight, T{0}, T{0} }, + { T{0}, T{0}, frange, T{0} }, + { -(left + right) * rwidth, -(top + bottom) * rheight, -frange * znear, T{1} }}; } template < typename T > @@ -682,10 +715,10 @@ namespace vmath_hpp const T frange = rcp(znear - zfar); return { - T{2} * rwidth, T{0}, T{0}, T{0}, - T{0}, T{2} * rheight, T{0}, T{0}, - T{0}, T{0}, frange, T{0}, - -(left + right) * rwidth, -(top + bottom) * rheight, frange * znear, T{1}}; + { T{2} * rwidth, T{0}, T{0}, T{0} }, + { T{0}, T{2} * rheight, T{0}, T{0} }, + { T{0}, T{0}, frange, T{0} }, + { -(left + right) * rwidth, -(top + bottom) * rheight, frange * znear, T{1} }}; } // perspective @@ -701,10 +734,10 @@ namespace vmath_hpp const T tz = (znear * zfar) * rcp(znear - zfar); return { - T{sx}, T{0}, T{0}, T{0}, - T{0}, T{sy}, T{0}, T{0}, - T{0}, T{0}, T{sz}, T{1}, - T{0}, T{0}, T{tz}, T{0}}; + { T{sx}, T{0}, T{0}, T{0} }, + { T{0}, T{sy}, T{0}, T{0} }, + { T{0}, T{0}, T{sz}, T{1} }, + { T{0}, T{0}, T{tz}, T{0} }}; } template < typename T > @@ -718,10 +751,10 @@ namespace vmath_hpp const T tz = (znear * zfar) * rcp(znear - zfar); return { - sx, T{0}, T{0}, T{0}, - T{0}, sy, T{0}, T{0}, - T{0}, T{0}, sz, -T{1}, - T{0}, T{0}, tz, T{0}}; + { sx, T{0}, T{0}, T{0} }, + { T{0}, sy, T{0}, T{0} }, + { T{0}, T{0}, sz, -T{1} }, + { T{0}, T{0}, tz, T{0} }}; } template < typename T > @@ -735,10 +768,10 @@ namespace vmath_hpp const T frange = zfar * rcp(zfar - znear); return { - znear2 * rwidth, T{0}, T{0}, T{0}, - T{0}, znear2 * rheight, T{0}, T{0}, - -(left + right) * rwidth, -(top + bottom) * rheight, frange, T{1}, - T{0}, T{0}, -frange * znear, T{0}}; + { znear2 * rwidth, T{0}, T{0}, T{0} }, + { T{0}, znear2 * rheight, T{0}, T{0} }, + { -(left + right) * rwidth, -(top + bottom) * rheight, frange, T{1} }, + { T{0}, T{0}, -frange * znear, T{0} }}; } template < typename T > @@ -752,10 +785,10 @@ namespace vmath_hpp const T frange = zfar * rcp(znear - zfar); return { - znear2 * rwidth, T{0}, T{0}, T{0}, - T{0}, znear2 * rheight, T{0}, T{0}, - (left + right) * rwidth, (top + bottom) * rheight, frange, -T{1}, - T{0}, T{0}, frange * znear, T{0}}; + { znear2 * rwidth, T{0}, T{0}, T{0} }, + { T{0}, znear2 * rheight, T{0}, T{0} }, + { (left + right) * rwidth, (top + bottom) * rheight, frange, -T{1} }, + { T{0}, T{0}, frange * znear, T{0} }}; } template < typename T > @@ -769,10 +802,10 @@ namespace vmath_hpp const T tz = (znear * zfar) * rcp(znear - zfar); return { - sx, T{0}, T{0}, T{0}, - T{0}, sy, T{0}, T{0}, - T{0}, T{0}, sz, T{1}, - T{0}, T{0}, tz, T{0}}; + { sx, T{0}, T{0}, T{0} }, + { T{0}, sy, T{0}, T{0} }, + { T{0}, T{0}, sz, T{1} }, + { T{0}, T{0}, tz, T{0} }}; } template < typename T > @@ -785,10 +818,10 @@ namespace vmath_hpp const T sz = zfar * rcp(znear - zfar); const T tz = (znear * zfar) * rcp(znear - zfar); return { - sx, T{0}, T{0}, T{0}, - T{0}, sy, T{0}, T{0}, - T{0}, T{0}, sz, -T{1}, - T{0}, T{0}, tz, T{0}}; + { sx, T{0}, T{0}, T{0} }, + { T{0}, sy, T{0}, T{0} }, + { T{0}, T{0}, sz, -T{1} }, + { T{0}, T{0}, tz, T{0} }}; } } @@ -810,10 +843,7 @@ namespace vmath_hpp template < typename T > [[nodiscard]] constexpr vec rotate(const vec& v, T angle) { - const auto [s, c] = sincos(angle); - return { - v.x * c - v.y * s, - v.x * s + v.y * c}; + return v * rotate(angle); } template < typename T > @@ -974,31 +1004,11 @@ namespace vmath_hpp template < typename T > [[nodiscard]] constexpr qua qlook_at_lh(const vec& dir, const vec& up) { - /// REFERENCE: - /// https://www.euclideanspace.com/maths/algebra/vectors/lookat/ - - const vec az = normalize(dir); - const vec ax = normalize(cross(up, az)); - const vec ay = cross(az, ax); - - return qrotate(mat{ - ax.x, ay.x, az.x, - ax.y, ay.y, az.y, - ax.z, ay.z, az.z}); + return qrotate(look_at_lh(dir, up)); } template < typename T > [[nodiscard]] constexpr qua qlook_at_rh(const vec& dir, const vec& up) { - /// REFERENCE: - /// https://www.euclideanspace.com/maths/algebra/vectors/lookat/ - - const vec az = normalize(-dir); - const vec ax = normalize(cross(up, az)); - const vec ay = cross(az, ax); - - return qrotate(mat{ - ax.x, ay.x, az.x, - ax.y, ay.y, az.y, - ax.z, ay.z, az.z}); + return qrotate(look_at_rh(dir, up)); } } diff --git a/untests/vmath_fix_tests.cpp b/untests/vmath_fix_tests.cpp index 0d5ba88..be0657d 100644 --- a/untests/vmath_fix_tests.cpp +++ b/untests/vmath_fix_tests.cpp @@ -388,26 +388,29 @@ namespace vmath_hpp template fix4x4f translate(const fix3f&); template fix4x4f translate(const fix4x4f&, const fix3f&); - template fix4x4f rotate(const qfix&); - template fix4x4f rotate(const fix4x4f&, const qfix&); - template fix4x4f rotate(fix, const fix3f&); - template fix4x4f rotate(const fix4x4f&, fix, const fix3f&); + template fix3x3f rotate(const qfix&); + template fix3x3f rotate(const fix3x3f&, const qfix&); + template fix3x3f rotate(fix, const fix3f&); + template fix3x3f rotate(const fix3x3f&, fix, const fix3f&); - template fix4x4f rotate_x(fix); - template fix4x4f rotate_x(const fix4x4f&, fix); + template fix3x3f rotate_x(fix); + template fix3x3f rotate_x(const fix3x3f&, fix); - template fix4x4f rotate_y(fix); - template fix4x4f rotate_y(const fix4x4f&, fix); + template fix3x3f rotate_y(fix); + template fix3x3f rotate_y(const fix3x3f&, fix); - template fix4x4f rotate_z(fix); - template fix4x4f rotate_z(const fix4x4f&, fix); + template fix3x3f rotate_z(fix); + template fix3x3f rotate_z(const fix3x3f&, fix); - template fix4x4f scale(fix, fix, fix); - template fix4x4f scale(const fix4x4f&, fix, fix, fix); - template fix4x4f scale(const fix3f&); - template fix4x4f scale(const fix4x4f&, const fix3f&); + template fix3x3f scale(fix, fix, fix); + template fix3x3f scale(const fix3x3f&, fix, fix, fix); + template fix3x3f scale(const fix3f&); + template fix3x3f scale(const fix3x3f&, const fix3f&); + template fix3x3f look_at_lh(const fix3f&, const fix3f&); template fix4x4f look_at_lh(const fix3f&, const fix3f&, const fix3f&); + + template fix3x3f look_at_rh(const fix3f&, const fix3f&); template fix4x4f look_at_rh(const fix3f&, const fix3f&, const fix3f&); } @@ -422,24 +425,24 @@ namespace vmath_hpp template fix3x3f translate(const fix2f&); template fix3x3f translate(const fix3x3f&, const fix2f&); - template fix3x3f rotate(fix); - template fix3x3f rotate(const fix3x3f&, fix); + template fix2x2f rotate(fix); + template fix2x2f rotate(const fix2x2f&, fix); - template fix3x3f scale(fix, fix); - template fix3x3f scale(const fix3x3f&, fix, fix); - template fix3x3f scale(const fix2f&); - template fix3x3f scale(const fix3x3f&, const fix2f&); + template fix2x2f scale(fix, fix); + template fix2x2f scale(const fix2x2f&, fix, fix); + template fix2x2f scale(const fix2f&); + template fix2x2f scale(const fix2x2f&, const fix2f&); - template fix3x3f shear(fix, fix); - template fix3x3f shear(const fix3x3f&, fix, fix); - template fix3x3f shear(const fix2f&); - template fix3x3f shear(const fix3x3f&, const fix2f&); + template fix2x2f shear(fix, fix); + template fix2x2f shear(const fix2x2f&, fix, fix); + template fix2x2f shear(const fix2f&); + template fix2x2f shear(const fix2x2f&, const fix2f&); - template fix3x3f shear_x(fix); - template fix3x3f shear_x(const fix3x3f&, fix); + template fix2x2f shear_x(fix); + template fix2x2f shear_x(const fix2x2f&, fix); - template fix3x3f shear_y(fix); - template fix3x3f shear_y(const fix3x3f&, fix); + template fix2x2f shear_y(fix); + template fix2x2f shear_y(const fix2x2f&, fix); } // diff --git a/untests/vmath_mat_fun_tests.cpp b/untests/vmath_mat_fun_tests.cpp index f3bb96e..ba6d96e 100644 --- a/untests/vmath_mat_fun_tests.cpp +++ b/untests/vmath_mat_fun_tests.cpp @@ -309,7 +309,7 @@ TEST_CASE("vmath/mat_fun") { { const fvec3 axis2 = normalize(fvec3(1.f, 2.f, 3.f)); - const fmat4 m2 = rotate(0.5f,axis2); + const fmat4 m2 = fmat4(rotate(0.5f,axis2)); const fmat4 rm2 = inverse(m2); CHECK(all(approx( unit4_z * m2 * rm2,