From b6e8b13d1bb4feb1fe4dd732fa9834d4423a2e5b Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Thu, 17 Jul 2014 17:01:18 +1000 Subject: [PATCH] Added error checking to Vector2::Normalize() --- src/utilities/vector2.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utilities/vector2.hpp b/src/utilities/vector2.hpp index 2be3d34..57c716c 100644 --- a/src/utilities/vector2.hpp +++ b/src/utilities/vector2.hpp @@ -43,6 +43,8 @@ public: } void Normalize() { double l = Length(); + if (l == 0) + throw(std::domain_error("Divide by zero")); x /= l; y /= l; }