summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2022-03-28 19:02:23 -0400
committerJon Santmyer <jon@jonsantmyer.com>2022-03-28 19:02:23 -0400
commit058a306651093f8acfc7b51a430d09b5397da0cc (patch)
tree6bf15b8fd186c90b8d945ec0f38e224c652c6aa9
parent8e34a3b5abf194851c1e15a5f2e23e08d23f6ab4 (diff)
downloadvex-058a306651093f8acfc7b51a430d09b5397da0cc.tar.gz
vex-058a306651093f8acfc7b51a430d09b5397da0cc.tar.bz2
vex-058a306651093f8acfc7b51a430d09b5397da0cc.zip
Fix magnitude using wrong sqrt
-rw-r--r--vex.hpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/vex.hpp b/vex.hpp
index 9ef62dd..e75ea7e 100644
--- a/vex.hpp
+++ b/vex.hpp
@@ -54,7 +54,7 @@ struct vec_dimd
}
/*Finds the distance from the origin to the ray cast in D dimension space using components of vec*/
- constexpr T magnitude() const { T t{}; for(size_t i = 0; i < D; i++) t += v[i] * v[i]; return std::pow(t, 1./D); }
+ constexpr T magnitude() const { T t{}; for(size_t i = 0; i < D; i++) t += v[i] * v[i]; return std::sqrt(t); }
/*Finds the dot product of itself and another vec of same T and D*/
constexpr T dot(const vec_dimd<T, D> &b) const { T t; for(size_t i = 0; i < D; i++) t += (v[i] * b.v[i]); return t; }