From e06d009cdbcff920eced66e2a1e1b38327f3e84d Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Sat, 27 Feb 2021 06:22:33 +0700 Subject: [PATCH] less translate function variants --- README.md | 12 ------------ headers/vmath.hpp/vmath_ext.hpp | 28 ++++------------------------ untests/vmath_fix_tests.cpp | 4 ---- 3 files changed, 4 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 24ff266..c6a8cd9 100644 --- a/README.md +++ b/README.md @@ -1799,12 +1799,6 @@ qua imag(qua q, const vec& imag); ### Matrix Transform 3D ```cpp -template < typename T > -mat translate(T x, T y, T z); - -template < typename T > -mat translate(const mat& m, T x, T y, T z); - template < typename T > mat translate(const vec& v); @@ -1869,12 +1863,6 @@ mat look_at_rh(const vec& eye, const vec& at, const vec& ### Matrix Transform 2D ```cpp -template < typename T > -mat translate(T x, T y); - -template < typename T > -mat translate(const mat& m, T x, T y); - template < typename T > mat translate(const vec& v); diff --git a/headers/vmath.hpp/vmath_ext.hpp b/headers/vmath.hpp/vmath_ext.hpp index a253aeb..d328b5c 100644 --- a/headers/vmath.hpp/vmath_ext.hpp +++ b/headers/vmath.hpp/vmath_ext.hpp @@ -233,7 +233,7 @@ namespace vmath_hpp // translate template < typename T > - [[nodiscard]] constexpr mat translate(T x, T y, T z) { + [[nodiscard]] constexpr mat translate(const vec& v) { /// REFERENCE: /// https://en.wikipedia.org/wiki/Translation_(geometry) @@ -241,17 +241,7 @@ namespace vmath_hpp { 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 > - [[nodiscard]] constexpr mat translate(const mat& m, T x, T y, T z) { - return m * translate(x, y, z); - } - - template < typename T > - [[nodiscard]] constexpr mat translate(const vec& v) { - return translate(v.x, v.y, v.z); + { v.x, v.y, v.z, T{1} }}; } template < typename T > @@ -519,24 +509,14 @@ namespace vmath_hpp // translate template < typename T > - [[nodiscard]] constexpr mat translate(T x, T y) { + [[nodiscard]] constexpr mat translate(const vec& v) { /// REFERENCE: /// https://en.wikipedia.org/wiki/Translation_(geometry) return { { T{1}, T{0}, T{0} }, { T{0}, T{1}, T{0} }, - { x, y, T{1} }}; - } - - template < typename T > - [[nodiscard]] constexpr mat translate(const mat& m, T x, T y) { - return m * translate(x, y); - } - - template < typename T > - [[nodiscard]] constexpr mat translate(const vec& v) { - return translate(v.x, v.y); + { v.x, v.y, T{1} }}; } template < typename T > diff --git a/untests/vmath_fix_tests.cpp b/untests/vmath_fix_tests.cpp index 33fc7f6..e76fdc8 100644 --- a/untests/vmath_fix_tests.cpp +++ b/untests/vmath_fix_tests.cpp @@ -383,8 +383,6 @@ namespace vmath_hpp namespace vmath_hpp { - template fix4x4f translate(fix x, fix y, fix z); - template fix4x4f translate(const fix4x4f&, fix, fix, fix); template fix4x4f translate(const fix3f&); template fix4x4f translate(const fix4x4f&, const fix3f&); @@ -420,8 +418,6 @@ namespace vmath_hpp namespace vmath_hpp { - template fix3x3f translate(fix, fix); - template fix3x3f translate(const fix3x3f&, fix, fix); template fix3x3f translate(const fix2f&); template fix3x3f translate(const fix3x3f&, const fix2f&);