Browse Source

Avoid 0 divisor in Vector2's normalize method

Patrick-Christopher Mattulat 1 year ago
parent
commit
c446ba702f
1 changed files with 1 additions and 1 deletions
  1. 1 1
      source/ls-math/vector/Vector2.cpp

+ 1 - 1
source/ls-math/vector/Vector2.cpp

@@ -68,7 +68,7 @@ ls::math::core::type::vector2_component ls::math::vector::Vector2::getY()
 
 
 ls::math::vector::Vector2 ls::math::vector::Vector2::normalize()
 ls::math::vector::Vector2 ls::math::vector::Vector2::normalize()
 {
 {
-  double length = ls::math::vector::Vector2::_getLength(this->components[0], this->components[1]);
+  double length = ls::math::vector::Vector2::_getLength(this->components[0], this->components[1]) + std::numeric_limits<double>::min();
   return ls::math::vector::Vector2::_operatorDivision(this->components[0], this->components[1], length);
   return ls::math::vector::Vector2::_operatorDivision(this->components[0], this->components[1], length);
 }
 }