fix normalize

v1
Brett 2023-03-14 18:04:53 -04:00
parent b51a5363b2
commit 86820b779d
1 changed files with 5 additions and 2 deletions

View File

@ -63,8 +63,11 @@ namespace blt {
return std::sqrt(total);
}
[[nodiscard]] inline vec<T, size> normalize() const {
return *this / this->magnitude();
[[nodiscard]] inline vec<T, size>& normalize() const {
auto mag = this->magnitude();
if (mag == 0)
return *this;
return *this / mag;
}
inline T& operator[](int index) {