Sfoglia il codice sorgente

Avoid 0 divisor in Vector2's normalize method

Patrick-Christopher Mattulat 1 anno fa
parent
commit
c446ba702f
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  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()
 {
-  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);
 }