fix: division by zero in normalizing

main
Sara 2025-01-09 21:56:59 +01:00
parent 1d7c318a3d
commit 4fb9a645d8
1 changed files with 2 additions and 1 deletions

View File

@ -59,7 +59,8 @@ Vecf Vecf::rotated(float t) const {
} }
Vecf Vecf::normalized() const { Vecf Vecf::normalized() const {
return *this / this->magnitude(); float const magnitude{this->magnitude()};
return magnitude > 0.f ? *this / this->magnitude() : ce::Vecf::ZERO;
} }
Vecf Vecf::reciprocal() const { Vecf Vecf::reciprocal() const {