Added error checking to Vector2::Normalize()

This commit is contained in:
Kayne Ruse
2014-07-17 17:01:18 +10:00
parent a13c7cc053
commit b6e8b13d1b
+2
View File
@@ -43,6 +43,8 @@ public:
} }
void Normalize() { void Normalize() {
double l = Length(); double l = Length();
if (l == 0)
throw(std::domain_error("Divide by zero"));
x /= l; x /= l;
y /= l; y /= l;
} }