diff --git a/build/assets/include/linalg.hpp b/build/assets/include/linalg.hpp index b900320..de26bd8 100644 --- a/build/assets/include/linalg.hpp +++ b/build/assets/include/linalg.hpp @@ -495,6 +495,7 @@ namespace linalg template T uangle (const vec & a, const vec & b) { T d=dot(a,b); return d > 1 ? 0 : std::acos(d < -1 ? -1 : d); } template T angle (const vec & a, const vec & b) { return uangle(normalize(a), normalize(b)); } template vec rot (T a, const vec & v) { const T s = std::sin(a), c = std::cos(a); return {v.x*c - v.y*s, v.x*s + v.y*c}; } + template constexpr vec reflect (const vec & i, const vec & n) { return i-2*dot(n, i)*n; } template vec nlerp (const vec & a, const vec & b, T t) { return normalize(lerp(a,b,t)); } template vec slerp (const vec & a, const vec & b, T t) { T th=uangle(a,b); return th == 0 ? a : a*(std::sin(th*(1-t))/std::sin(th)) + b*(std::sin(th*t)/std::sin(th)); } diff --git a/src/games/playground/awoo.cpp b/src/games/playground/awoo.cpp index 31c0c5d..a301247 100644 --- a/src/games/playground/awoo.cpp +++ b/src/games/playground/awoo.cpp @@ -4,8 +4,9 @@ using namespace linalg::aliases; EXPORT(main) auto init() { - double2 dir = {0, -1}; - double2 rot = linalg::rot(3.14 / 2, dir); + static constexpr double2 vel = {-1, -1}; + static constexpr double2 left = {1, 0}; + static constexpr double2 refl = linalg::reflect(vel, left); - return linalg::angle(rot, {0, 1}); + return refl.y; } \ No newline at end of file