Added error checking to Vector2::Normalize()
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user