From de7a1683772f79b47d46a1ee82175ec5e7373e94 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Wed, 12 Oct 2016 21:49:28 +0200 Subject: [PATCH] vectors.py: Don't error out when normalizing zero length vectors --- boxes/vectors.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boxes/vectors.py b/boxes/vectors.py index 12337ce..d4e02d2 100644 --- a/boxes/vectors.py +++ b/boxes/vectors.py @@ -18,6 +18,8 @@ import math def normalize(v): "set lenght of vector to one" l = (v[0] ** 2 + v[1] ** 2) ** 0.5 + if l == 0.0: + return (0.0, 0.0) return (v[0] / l, v[1] / l)