From 61e6834b45c3bff11a025372427ad44d9caa80fb Mon Sep 17 00:00:00 2001 From: craftablescience Date: Sat, 3 Aug 2024 16:32:50 -0400 Subject: [PATCH] feat(sourcepp): add vector scale method --- include/sourcepp/math/Vector.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/sourcepp/math/Vector.h b/include/sourcepp/math/Vector.h index c74e4f799..a30d39ae7 100644 --- a/include/sourcepp/math/Vector.h +++ b/include/sourcepp/math/Vector.h @@ -211,12 +211,17 @@ struct Vec { } template - [[nodiscard]] constexpr P dot(const Vec& other) const { + [[nodiscard]] constexpr Vec scale(const Vec& other) const { Vec out; for (uint8_t i = 0; i < S; i++) { out[i] = (*this)[i] * static_cast

(other[i]); } - return out.sum(); + return out; + } + + template + [[nodiscard]] constexpr P dot(const Vec& other) const { + return this->scale(other).sum(); } [[nodiscard]] constexpr Vec abs() const {