Переглянути джерело

Avoid 0 divisor in Vector2's normalize method

Patrick-Christopher Mattulat 1 рік тому
батько
коміт
c446ba702f
1 змінених файлів з 1 додано та 1 видалено
  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);
 }