소스 검색

Avoid 0 divisor in Vector2's normalize method

Patrick-Christopher Mattulat 2 년 전
부모
커밋
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);
 }