clean up ext api

This commit is contained in:
BlackMATov
2021-02-27 07:53:16 +07:00
parent ebdcb4f495
commit b8cb43c454
4 changed files with 1 additions and 292 deletions

View File

@@ -1814,81 +1814,42 @@ mat<T, 4> trs(const vec<T, 3>& t, const qua<T>& r, const vec<T, 3>& s);
template < typename T >
mat<T, 4> translate(const vec<T, 3>& v);
template < typename T >
mat<T, 4> translate(const mat<T, 4>& m, const vec<T, 3>& v);
template < typename T >
mat<T, 3> rotate(const qua<T>& q);
template < typename T >
mat<T, 3> rotate(const mat<T, 3>& m, const qua<T>& q);
template < typename T >
mat<T, 4> rotate4(const qua<T>& q);
template < typename T >
mat<T, 4> rotate4(const mat<T, 4>& m, const qua<T>& q);
template < typename T >
mat<T, 3> rotate(T angle, const vec<T, 3>& axis);
template < typename T >
mat<T, 3> rotate(const mat<T, 3>& m, T angle, const vec<T, 3>& axis);
template < typename T >
mat<T, 4> rotate4(T angle, const vec<T, 3>& axis);
template < typename T >
mat<T, 4> rotate4(const mat<T, 4>& m, T angle, const vec<T, 3>& axis);
template < typename T >
mat<T, 3> rotate_x(T angle);
template < typename T >
mat<T, 3> rotate_x(const mat<T, 3>& m, T angle);
template < typename T >
mat<T, 4> rotate4_x(T angle);
template < typename T >
mat<T, 4> rotate4_x(const mat<T, 4>& m, T angle);
template < typename T >
mat<T, 3> rotate_y(T angle);
template < typename T >
mat<T, 3> rotate_y(const mat<T, 3>& m, T angle);
template < typename T >
mat<T, 4> rotate4_y(T angle);
template < typename T >
mat<T, 4> rotate4_y(const mat<T, 4>& m, T angle);
template < typename T >
mat<T, 3> rotate_z(T angle);
template < typename T >
mat<T, 3> rotate_z(const mat<T, 3>& m, T angle);
template < typename T >
mat<T, 4> rotate4_z(T angle);
template < typename T >
mat<T, 4> rotate4_z(const mat<T, 4>& m, T angle);
template < typename T >
mat<T, 3> scale(const vec<T, 3>& v);
template < typename T >
mat<T, 3> scale(const mat<T, 3>& m, const vec<T, 3>& v);
template < typename T >
mat<T, 4> scale4(const vec<T, 3>& v);
template < typename T >
mat<T, 4> scale4(const mat<T, 4>& m, const vec<T, 3>& v);
template < typename T >
mat<T, 3> look_at_lh(const vec<T, 3>& dir, const vec<T, 3>& up);
@@ -1914,44 +1875,23 @@ mat<T, 3> trs(const vec<T, 2>& t, const mat<T, 2>& r, const vec<T, 2>& s);
template < typename T >
mat<T, 3> translate(const vec<T, 2>& v);
template < typename T >
mat<T, 3> translate(const mat<T, 3>& m, const vec<T, 2>& v);
template < typename T >
mat<T, 2> rotate(T angle);
template < typename T >
mat<T, 2> rotate(const mat<T, 2>& m, T angle);
template < typename T >
mat<T, 3> rotate3(T angle);
template < typename T >
mat<T, 3> rotate3(const mat<T, 3>& m, T angle);
template < typename T >
mat<T, 2> scale(const vec<T, 2>& v);
template < typename T >
mat<T, 2> scale(const mat<T, 2>& m, const vec<T, 2>& v);
template < typename T >
mat<T, 3> scale3(const vec<T, 2>& v);
template < typename T >
mat<T, 3> scale3(const mat<T, 3>& m, const vec<T, 2>& v);
template < typename T >
mat<T, 2> shear(const vec<T, 2>& v);
template < typename T >
mat<T, 2> shear(const mat<T, 2>& m, const vec<T, 2>& v);
template < typename T >
mat<T, 3> shear3(const vec<T, 2>& v);
template < typename T >
mat<T, 3> shear3(const mat<T, 3>& m, const vec<T, 2>& v);
```
### Matrix Projections
@@ -2006,9 +1946,6 @@ vec<T, 3> rotate_y(const vec<T, 3>& v, T angle);
template < typename T >
vec<T, 3> rotate_z(const vec<T, 3>& v, T angle);
template < typename T >
vec<T, 3> rotate(const vec<T, 3>& v, const qua<T>& q);
template < typename T >
vec<T, 3> rotate(const vec<T, 3>& v, T angle, const vec<T, 3>& axis);

View File

@@ -274,11 +274,6 @@ namespace vmath_hpp
{ v.x, v.y, v.z, T{1} }};
}
template < typename T >
[[nodiscard]] constexpr mat<T, 4> translate(const mat<T, 4>& m, const vec<T, 3>& v) {
return m * translate(v);
}
// rotate
template < typename T >
@@ -310,21 +305,11 @@ namespace vmath_hpp
{ (xz2 + sy2), (yz2 - sx2), T{1} - (xx2 + yy2) }};
}
template < typename T >
[[nodiscard]] constexpr mat<T, 3> rotate(const mat<T, 3>& m, const qua<T>& q) {
return m * rotate(q);
}
template < typename T >
[[nodiscard]] constexpr mat<T, 4> rotate4(const qua<T>& q) {
return mat<T, 4>(rotate(q));
}
template < typename T >
[[nodiscard]] constexpr mat<T, 4> rotate4(const mat<T, 4>& m, const qua<T>& q) {
return m * rotate4(q);
}
template < typename T >
[[nodiscard]] constexpr mat<T, 3> rotate(T angle, const vec<T, 3>& axis) {
/// REFERENCE:
@@ -357,21 +342,11 @@ namespace vmath_hpp
{ xzm + ys, yzm - xs, zzm + c }};
}
template < typename T >
[[nodiscard]] constexpr mat<T, 3> rotate(const mat<T, 3>& m, T angle, const vec<T, 3>& axis) {
return m * rotate(angle, axis);
}
template < typename T >
[[nodiscard]] constexpr mat<T, 4> rotate4(T angle, const vec<T, 3>& axis) {
return mat<T, 4>(rotate(angle, axis));
}
template < typename T >
[[nodiscard]] constexpr mat<T, 4> rotate4(const mat<T, 4>& m, T angle, const vec<T, 3>& axis) {
return m * rotate4(angle, axis);
}
// rotate_x
template < typename T >
@@ -387,21 +362,11 @@ namespace vmath_hpp
{ T{0}, -s, c }};
}
template < typename T >
[[nodiscard]] constexpr mat<T, 3> rotate_x(const mat<T, 3>& m, T angle) {
return m * rotate_x(angle);
}
template < typename T >
[[nodiscard]] constexpr mat<T, 4> rotate4_x(T angle) {
return mat<T, 4>(rotate_x(angle));
}
template < typename T >
[[nodiscard]] constexpr mat<T, 4> rotate4_x(const mat<T, 4>& m, T angle) {
return m * rotate4_x(angle);
}
// rotate_y
template < typename T >
@@ -417,21 +382,11 @@ namespace vmath_hpp
{ s, T{0}, c }};
}
template < typename T >
[[nodiscard]] constexpr mat<T, 3> rotate_y(const mat<T, 3>& m, T angle) {
return m * rotate_y(angle);
}
template < typename T >
[[nodiscard]] constexpr mat<T, 4> rotate4_y(T angle) {
return mat<T, 4>(rotate_y(angle));
}
template < typename T >
[[nodiscard]] constexpr mat<T, 4> rotate4_y(const mat<T, 4>& m, T angle) {
return m * rotate4_y(angle);
}
// rotate_z
template < typename T >
@@ -447,21 +402,11 @@ namespace vmath_hpp
{ T{0}, T{0}, T{1} }};
}
template < typename T >
[[nodiscard]] constexpr mat<T, 3> rotate_z(const mat<T, 3>& m, T angle) {
return m * rotate_z(angle);
}
template < typename T >
[[nodiscard]] constexpr mat<T, 4> rotate4_z(T angle) {
return mat<T, 4>(rotate_z(angle));
}
template < typename T >
[[nodiscard]] constexpr mat<T, 4> rotate4_z(const mat<T, 4>& m, T angle) {
return m * rotate4_z(angle);
}
// scale
template < typename T >
@@ -475,23 +420,11 @@ namespace vmath_hpp
{ T{0}, T{0}, v.z }};
}
template < typename T >
[[nodiscard]] constexpr mat<T, 3> scale(const mat<T, 3>& m, const vec<T, 3>& v) {
return m * scale(v);
}
// scale4
template < typename T >
[[nodiscard]] constexpr mat<T, 4> scale4(const vec<T, 3>& v) {
return mat<T, 4>(scale(v));
}
template < typename T >
[[nodiscard]] constexpr mat<T, 4> scale4(const mat<T, 4>& m, const vec<T, 3>& v) {
return m * scale4(v);
}
// look_at
template < typename T >
@@ -616,11 +549,6 @@ namespace vmath_hpp
{ v.x, v.y, T{1} }};
}
template < typename T >
[[nodiscard]] constexpr mat<T, 3> translate(const mat<T, 3>& m, const vec<T, 2>& v) {
return m * translate(v);
}
// rotate
template < typename T >
@@ -635,21 +563,11 @@ namespace vmath_hpp
{ -s, c }};
}
template < typename T >
[[nodiscard]] constexpr mat<T, 2> rotate(const mat<T, 2>& m, T angle) {
return m * rotate(angle);
}
template < typename T >
[[nodiscard]] constexpr mat<T, 3> rotate3(T angle) {
return mat<T, 3>(rotate(angle));
}
template < typename T >
[[nodiscard]] constexpr mat<T, 3> rotate3(const mat<T, 3>& m, T angle) {
return m * rotate3(angle);
}
// scale
template < typename T >
@@ -662,21 +580,11 @@ namespace vmath_hpp
{ T{0}, v.y }};
}
template < typename T >
[[nodiscard]] constexpr mat<T, 2> scale(const mat<T, 2>& m, const vec<T, 2>& v) {
return m * scale(v);
}
template < typename T >
[[nodiscard]] constexpr mat<T, 3> scale3(const vec<T, 2>& v) {
return mat<T, 3>(scale(v));
}
template < typename T >
[[nodiscard]] constexpr mat<T, 3> scale3(const mat<T, 3>& m, const vec<T, 2>& v) {
return m * scale3(v);
}
// shear
template < typename T >
@@ -689,20 +597,10 @@ namespace vmath_hpp
{ v.x, T{1} }};
}
template < typename T >
[[nodiscard]] constexpr mat<T, 2> shear(const mat<T, 2>& m, const vec<T, 2>& v) {
return m * shear(v);
}
template < typename T >
[[nodiscard]] constexpr mat<T, 3> shear3(const vec<T, 2>& v) {
return mat<T, 3>(shear(v));
}
template < typename T >
[[nodiscard]] constexpr mat<T, 3> shear3(const mat<T, 3>& m, const vec<T, 2>& v) {
return m * shear3(v);
}
}
//
@@ -927,11 +825,6 @@ namespace vmath_hpp
return v * qrotate(angle, unit3_z<T>);
}
template < typename T >
[[nodiscard]] constexpr vec<T, 3> rotate(const vec<T, 3>& v, const qua<T>& q) {
return v * q;
}
template < typename T >
[[nodiscard]] constexpr vec<T, 3> rotate(const vec<T, 3>& v, T angle, const vec<T, 3>& axis) {
return v * qrotate(angle, axis);
@@ -978,11 +871,6 @@ namespace vmath_hpp
T{1}}));
}
template < typename T >
[[nodiscard]] constexpr qua<T> qrotate(const qua<T>& q, const mat<T, 3>& m) {
return q * qrotate(m);
}
template < typename T >
[[nodiscard]] constexpr qua<T> qrotate(const vec<T, 3>& from, const vec<T, 3>& to) {
/// REFERENCE:
@@ -1000,11 +888,6 @@ namespace vmath_hpp
return normalize(qua{cross(from, to), s});
}
template < typename T >
[[nodiscard]] constexpr qua<T> qrotate(const qua<T>& q, const vec<T, 3>& from, const vec<T, 3>& to) {
return q * qrotate(from, to);
}
template < typename T >
[[nodiscard]] constexpr qua<T> qrotate(T angle, const vec<T, 3>& axis) {
/// REFERENCE:
@@ -1016,11 +899,6 @@ namespace vmath_hpp
return {vec{x, y, z} * s, c};
}
template < typename T >
[[nodiscard]] constexpr qua<T> qrotate(const qua<T>& q, T angle, const vec<T, 3>& axis) {
return q * qrotate(angle, axis);
}
template < typename T >
[[nodiscard]] constexpr qua<T> qrotate_x(T angle) {
/// REFERENCE:
@@ -1031,11 +909,6 @@ namespace vmath_hpp
return {vec{s, T{0}, T{0}}, c};
}
template < typename T >
[[nodiscard]] constexpr qua<T> qrotate_x(const qua<T>& q, T angle) {
return qrotate(q, angle, unit3_x<T>);
}
template < typename T >
[[nodiscard]] constexpr qua<T> qrotate_y(T angle) {
/// REFERENCE:
@@ -1046,11 +919,6 @@ namespace vmath_hpp
return {vec{T{0}, s, T{0}}, c};
}
template < typename T >
[[nodiscard]] constexpr qua<T> qrotate_y(const qua<T>& q, T angle) {
return qrotate(q, angle, unit3_y<T>);
}
template < typename T >
[[nodiscard]] constexpr qua<T> qrotate_z(T angle) {
/// REFERENCE:
@@ -1061,12 +929,7 @@ namespace vmath_hpp
return {vec{T{0}, T{0}, s}, c};
}
template < typename T >
[[nodiscard]] constexpr qua<T> qrotate_z(const qua<T>& q, T angle) {
return qrotate(q, angle, unit3_z<T>);
}
// look_at
// qlook_at
template < typename T >
[[nodiscard]] constexpr qua<T> qlook_at_lh(const vec<T, 3>& dir, const vec<T, 3>& up) {

View File

@@ -18,7 +18,6 @@ namespace
constexpr float pi = radians(180.f);
constexpr float pi_2 = radians(90.f);
constexpr float pi_4 = radians(45.f);
}
TEST_CASE("vmath/ext/units") {
@@ -243,10 +242,7 @@ TEST_CASE("vmath/ext/matrix_transform") {
SUBCASE("translate") {
STATIC_CHECK(fvec3(2.f,3.f,1.f) * translate(fvec2{1.f,2.f}) == uapprox3(3.f,5.f,1.f));
STATIC_CHECK(fvec3(2.f,3.f,1.f) * translate(translate(fvec2{1.f,2.f}), fvec2{1.f,2.f}) == uapprox3(4.f,7.f,1.f));
STATIC_CHECK(fvec4(2.f,3.f,4.f,1.f) * translate(fvec3{1.f,2.f,3.f}) == uapprox4(3.f,5.f,7.f,1.f));
STATIC_CHECK(fvec4(2.f,3.f,4.f,1.f) * translate(translate(fvec3{1.f,2.f,3.f}), fvec3{1.f,2.f,3.f}) == uapprox4(4.f,7.f,10.f,1.f));
}
SUBCASE("rotate") {
@@ -257,17 +253,8 @@ TEST_CASE("vmath/ext/matrix_transform") {
CHECK(fvec4(0.f,0.f,1.f,1.f) * rotate4_y(pi_2) == uapprox4(1.f,0.f,0.f,1.f));
CHECK(fvec4(1.f,0.f,0.f,1.f) * rotate4_z(pi_2) == uapprox4(0.f,1.f,0.f,1.f));
CHECK(fvec3(0.f,1.f,0.f) * rotate_x(rotate_x(pi_4),pi_4) == uapprox3(0.f,0.f,1.f));
CHECK(fvec3(0.f,0.f,1.f) * rotate_y(rotate_y(pi_4),pi_4) == uapprox3(1.f,0.f,0.f));
CHECK(fvec3(1.f,0.f,0.f) * rotate_z(rotate_z(pi_4),pi_4) == uapprox3(0.f,1.f,0.f));
CHECK(fvec4(0.f,1.f,0.f,1.f) * rotate4_x(rotate4_x(pi_4),pi_4) == uapprox4(0.f,0.f,1.f,1.f));
CHECK(fvec4(0.f,0.f,1.f,1.f) * rotate4_y(rotate4_y(pi_4),pi_4) == uapprox4(1.f,0.f,0.f,1.f));
CHECK(fvec4(1.f,0.f,0.f,1.f) * rotate4_z(rotate4_z(pi_4),pi_4) == uapprox4(0.f,1.f,0.f,1.f));
CHECK(fvec2(2.f,3.f) * rotate(pi) == uapprox2(-2.f,-3.f));
CHECK(fvec2(2.f,3.f) * rotate(rotate(pi_2),pi_2) == uapprox2(-2.f,-3.f));
CHECK(fvec3(2.f,3.f,1) * rotate3(pi) == uapprox3(-2.f,-3.f,1.f));
CHECK(fvec3(2.f,3.f,1) * rotate3(rotate3(pi_2),pi_2) == uapprox3(-2.f,-3.f,1.f));
CHECK(fvec3(2.f,3.f,4.f) * rotate(pi,{0.f,0.f,1.f}) == uapprox3(-2.f,-3.f,4.f));
CHECK(fvec3(2.f,3.f,4.f) * rotate(pi,fvec3{0.f,0.f,1.f}) == uapprox3(-2.f,-3.f,4.f));
@@ -275,29 +262,16 @@ TEST_CASE("vmath/ext/matrix_transform") {
CHECK(fvec4(2.f,3.f,4.f,1.f) * rotate4(pi,{0.f,0.f,1.f}) == uapprox4(-2.f,-3.f,4.f,1.f));
CHECK(fvec4(2.f,3.f,4.f,1.f) * rotate4(pi,fvec3{0.f,0.f,1.f}) == uapprox4(-2.f,-3.f,4.f,1.f));
CHECK(fvec4(2.f,3.f,4.f,1.f) * rotate4(qrotate(pi,fvec3{0.f,0.f,1.f})) == uapprox4(-2.f,-3.f,4.f,1.f));
CHECK(fvec3(2.f,3.f,4.f) * rotate(rotate(pi_2,{0.f,0.f,1.f}),pi_2,{0.f,0.f,1.f}) == uapprox3(-2.f,-3.f,4.f));
CHECK(fvec3(2.f,3.f,4.f) * rotate(rotate(pi_2,fvec3{0.f,0.f,1.f}),pi_2,fvec3{0.f,0.f,1.f}) == uapprox3(-2.f,-3.f,4.f));
CHECK(fvec3(2.f,3.f,4.f) * rotate(rotate(qrotate(pi_2,fvec3{0.f,0.f,1.f})),qrotate(pi_2,fvec3{0.f,0.f,1.f})) == uapprox3(-2.f,-3.f,4.f));
CHECK(fvec4(2.f,3.f,4.f,1.f) * rotate4(rotate4(pi_2,{0.f,0.f,1.f}),pi_2,{0.f,0.f,1.f}) == uapprox4(-2.f,-3.f,4.f,1.f));
CHECK(fvec4(2.f,3.f,4.f,1.f) * rotate4(rotate4(pi_2,fvec3{0.f,0.f,1.f}),pi_2,fvec3{0.f,0.f,1.f}) == uapprox4(-2.f,-3.f,4.f,1.f));
CHECK(fvec4(2.f,3.f,4.f,1.f) * rotate4(rotate4(qrotate(pi_2,fvec3{0.f,0.f,1.f})),qrotate(pi_2,fvec3{0.f,0.f,1.f})) == uapprox4(-2.f,-3.f,4.f,1.f));
}
SUBCASE("scale2d") {
STATIC_CHECK(fvec2(2.f,3.f) * scale(fvec2{2.f,3.f}) == uapprox2(4.f,9.f));
STATIC_CHECK(fvec3(2.f,3.f,1.f) * scale3(fvec2{2.f,3.f}) == uapprox3(4.f,9.f,1.f));
STATIC_CHECK(fvec2(2.f,3.f) * scale(scale(fvec2{2.f,2.f}), fvec2{2.f,3.f}) == uapprox2(8.f,18.f));
STATIC_CHECK(fvec3(2.f,3.f,1.f) * scale3(scale3(fvec2{2.f,2.f}), fvec2{2.f,3.f}) == uapprox3(8.f,18.f,1.f));
}
SUBCASE("scale3d") {
STATIC_CHECK(fvec3(2.f,3.f,4.f) * scale(fvec3{2.f,3.f,4.f}) == uapprox3(4.f,9.f,16.f));
STATIC_CHECK(fvec4(2.f,3.f,4.f,1.f) * scale4(fvec3{2.f,3.f,4.f}) == uapprox4(4.f,9.f,16.f,1.f));
STATIC_CHECK(fvec3(2.f,3.f,4.f) * scale(scale(fvec3{2.f,2.f,2.f}), fvec3{2.f,3.f,4.f}) == uapprox3(8.f,18.f,32.f));
STATIC_CHECK(fvec4(2.f,3.f,4.f,1.f) * scale4(scale4(fvec3{2.f,2.f,2.f}), fvec3{2.f,3.f,4.f}) == uapprox4(8.f,18.f,32.f,1.f));
}
SUBCASE("shear") {
@@ -307,11 +281,6 @@ TEST_CASE("vmath/ext/matrix_transform") {
STATIC_CHECK(fvec3(2.f,3.f,1.f) * shear3(fvec2(0.f,0.f)) == uapprox3(2.f,3.f,1.f));
STATIC_CHECK(fvec3(2.f,3.f,1.f) * shear3(fvec2(2.f,0.f)) == uapprox3(8.f,3.f,1.f));
STATIC_CHECK(fvec3(2.f,3.f,1.f) * shear3(fvec2(0.f,2.f)) == uapprox3(2.f,7.f,1.f));
STATIC_CHECK(fvec2(2.f,3.f) * shear(shear(fvec2(1.f,0.f)),fvec2(1.f,0.f)) == uapprox2(8.f,3.f));
STATIC_CHECK(fvec2(2.f,3.f) * shear(shear(fvec2(0.f,1.f)),fvec2(0.f,1.f)) == uapprox2(2.f,7.f));
STATIC_CHECK(fvec3(2.f,3.f,1.f) * shear3(shear3(fvec2(1.f,0.f)),fvec2(1.f,0.f)) == uapprox3(8.f,3.f,1.f));
STATIC_CHECK(fvec3(2.f,3.f,1.f) * shear3(shear3(fvec2(0.f,1.f)),fvec2(0.f,1.f)) == uapprox3(2.f,7.f,1.f));
}
SUBCASE("matrix look_at") {
@@ -365,7 +334,6 @@ TEST_CASE("vmath/ext/vector_transform") {
CHECK(rotate_y(fvec3(0.f,0.f,1.5f), radians(90.f)) == uapprox3(1.5f,0.f,0.f));
CHECK(rotate_z(fvec3(1.5f,0.f,0.f), radians(90.f)) == uapprox3(0.f,1.5f,0.f));
CHECK(rotate(fvec3(1.5f,0.f,0.f), qrotate_z(radians(90.f))) == uapprox3(0.f,1.5f,0.f));
CHECK(rotate(fvec3(1.5f,0.f,0.f), radians(90.f), fvec3(0,0,1)) == uapprox3(0.f,1.5f,0.f));
}
@@ -393,16 +361,6 @@ TEST_CASE("vmath/ext/quaternion_transform") {
vec{4.f,3.f,2.f} * rotate(radians(-190.5f), vec{1.f,2.f,3.f}), 0.001f)));
}
SUBCASE("qrotate(q, m)") {
CHECK(all(approx(
vec{4.f,3.f,2.f} * qrotate(
qrotate(rotate(0.f, vec{1.f,2.f,3.f})),
rotate(0.f, vec{3.f,2.f,1.f})),
vec{4.f,3.f,2.f} *
rotate(0.f, vec{1.f,2.f,3.f}) *
rotate(0.f, vec{3.f,2.f,1.f}))));
}
SUBCASE("qrotate(from, to)") {
CHECK(+unit3_x<float> * qrotate(-unit3_x<float>, +unit3_x<float>) == uapprox3(-unit3_x<float>));
CHECK(-unit3_y<float> * qrotate(+unit3_y<float>, -unit3_y<float>) == uapprox3(+unit3_y<float>));
@@ -411,15 +369,6 @@ TEST_CASE("vmath/ext/quaternion_transform") {
CHECK(vec{-2.f,1.f,3.f} * qrotate(vec{-2.f,1.f,3.f}, vec{1.f,2.f,3.f}) == uapprox3(1.f,2.f,3.f));
}
SUBCASE("qrotate(q, from, to)") {
CHECK(vec{1.f,2.f,3.f} *
inverse(qrotate(fmat3(rotate(radians(12.f), {2.f,2.f,2.f})))) *
qrotate(
qrotate(fmat3(rotate(radians(12.f), {2.f,2.f,2.f}))),
vec{1.f,2.f,3.f},
vec{-2.f,1.f,3.f}) == uapprox3(vec{-2.f,1.f,3.f}));
}
SUBCASE("qrotate(angle, axis)") {
CHECK(all(approx(
rotate(12.3f, fvec3(1.f,2.f,3.f)),
@@ -437,15 +386,6 @@ TEST_CASE("vmath/ext/quaternion_transform") {
CHECK(qrotate_z(12.3f) == qrotate(12.3f, unit3_z<float> * 2.f));
}
SUBCASE("qrotate(q, angle, axis)") {
CHECK(fvec3(0.f,1.f,0.f) * qrotate_x(qrotate_x(pi_4),pi_4) == uapprox3(0.f,0.f,1.f));
CHECK(fvec3(0.f,0.f,1.f) * qrotate_y(qrotate_y(pi_4),pi_4) == uapprox3(1.f,0.f,0.f));
CHECK(fvec3(1.f,0.f,0.f) * qrotate_z(qrotate_z(pi_4),pi_4) == uapprox3(0.f,1.f,0.f));
CHECK(fvec3(2.f,3.f,4.f) * qrotate(qrotate(pi_2,{0.f,0.f,1.f}),pi_2,{0.f,0.f,1.f}) == uapprox3(-2.f,-3.f,4.f));
CHECK(fvec3(2.f,3.f,4.f) * qrotate(qrotate(pi_2,fvec3{0.f,0.f,1.f}),pi_2,fvec3{0.f,0.f,1.f}) == uapprox3(-2.f,-3.f,4.f));
}
SUBCASE("qlook_at") {
CHECK(all(approx(
qlook_at_lh(fvec3(1.f,2.f,3.f), fvec3(0,1,0)),

View File

@@ -389,37 +389,24 @@ namespace vmath_hpp
template fix4x4f trs(const fix3f&, const qfix&, const fix3f&);
template fix4x4f translate(const fix3f&);
template fix4x4f translate(const fix4x4f&, const fix3f&);
template fix3x3f rotate(const qfix&);
template fix3x3f rotate(const fix3x3f&, const qfix&);
template fix4x4f rotate4(const qfix&);
template fix4x4f rotate4(const fix4x4f&, const qfix&);
template fix3x3f rotate(fix<float>, const fix3f&);
template fix3x3f rotate(const fix3x3f&, fix<float>, const fix3f&);
template fix4x4f rotate4(fix<float>, const fix3f&);
template fix4x4f rotate4(const fix4x4f&, fix<float>, const fix3f&);
template fix3x3f rotate_x(fix<float>);
template fix3x3f rotate_x(const fix3x3f&, fix<float>);
template fix4x4f rotate4_x(fix<float>);
template fix4x4f rotate4_x(const fix4x4f&, fix<float>);
template fix3x3f rotate_y(fix<float>);
template fix3x3f rotate_y(const fix3x3f&, fix<float>);
template fix4x4f rotate4_y(fix<float>);
template fix4x4f rotate4_y(const fix4x4f&, fix<float>);
template fix3x3f rotate_z(fix<float>);
template fix3x3f rotate_z(const fix3x3f&, fix<float>);
template fix4x4f rotate4_z(fix<float>);
template fix4x4f rotate4_z(const fix4x4f&, fix<float>);
template fix3x3f scale(const fix3f&);
template fix3x3f scale(const fix3x3f&, const fix3f&);
template fix4x4f scale4(const fix3f&);
template fix4x4f scale4(const fix4x4f&, const fix3f&);
template fix3x3f look_at_lh(const fix3f&, const fix3f&);
template fix4x4f look_at_lh(const fix3f&, const fix3f&, const fix3f&);
@@ -438,22 +425,15 @@ namespace vmath_hpp
template fix3x3f trs(const fix2f&, const fix2x2f&, const fix2f&);
template fix3x3f translate(const fix2f&);
template fix3x3f translate(const fix3x3f&, const fix2f&);
template fix2x2f rotate(fix<float>);
template fix2x2f rotate(const fix2x2f&, fix<float>);
template fix3x3f rotate3(fix<float>);
template fix3x3f rotate3(const fix3x3f&, fix<float>);
template fix2x2f scale(const fix2f&);
template fix2x2f scale(const fix2x2f&, const fix2f&);
template fix3x3f scale3(const fix2f&);
template fix3x3f scale3(const fix3x3f&, const fix2f&);
template fix2x2f shear(const fix2f&);
template fix2x2f shear(const fix2x2f&, const fix2f&);
template fix3x3f shear3(const fix2f&);
template fix3x3f shear3(const fix3x3f&, const fix2f&);
}
//
@@ -489,7 +469,6 @@ namespace vmath_hpp
template fix3f rotate_x(const fix3f&, fix<float>);
template fix3f rotate_y(const fix3f&, fix<float>);
template fix3f rotate_z(const fix3f&, fix<float>);
template fix3f rotate(const fix3f&, const qfix&);
template fix3f rotate(const fix3f&, fix<float>, const fix3f&);
template fix3f project(const fix3f&, const fix3f&);
template fix3f perpendicular(const fix3f&, const fix3f&);
@@ -502,22 +481,12 @@ namespace vmath_hpp
namespace vmath_hpp
{
template qfix qrotate(const fix3x3f&);
template qfix qrotate(const qfix&, const fix3x3f&);
template qfix qrotate(const fix3f&, const fix3f&);
template qfix qrotate(const qfix&, const fix3f&, const fix3f&);
template qfix qrotate(fix<float>, const fix3f&);
template qfix qrotate(const qfix&, fix<float>, const fix3f&);
template qfix qrotate_x(fix<float>);
template qfix qrotate_x(const qfix&, fix<float>);
template qfix qrotate_y(fix<float>);
template qfix qrotate_y(const qfix&, fix<float>);
template qfix qrotate_z(fix<float>);
template qfix qrotate_z(const qfix&, fix<float>);
template qfix qlook_at_lh(const fix3f&, const fix3f&);
template qfix qlook_at_rh(const fix3f&, const fix3f&);