mirror of
https://github.com/NoelFB/blah.git
synced 2024-11-28 16:58:57 +08:00
Vec2::normal accounts for zero-length
This commit is contained in:
parent
832c8f4283
commit
c8afa3f699
|
@ -456,6 +456,8 @@ namespace Blah
|
|||
template<class T>
|
||||
Vec2<T> Vec2<T>::normal() const {
|
||||
auto len = std::sqrt(x * x + y * y);
|
||||
if (len <= 0)
|
||||
return Vec2<T>(0, 0);
|
||||
return Vec2(x / len, y / len);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user