From e78c4a8cb53c027ec56349b2cabb734bdf234af2 Mon Sep 17 00:00:00 2001 From: Abhik Pal Date: Thu, 21 Sep 2017 15:02:30 +0200 Subject: [PATCH] BUG: Fixes #12. Vector.random_2d() returns negative values. --- p5/pmath/vector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/p5/pmath/vector.py b/p5/pmath/vector.py index 32f1d4ee..8249906a 100644 --- a/p5/pmath/vector.py +++ b/p5/pmath/vector.py @@ -408,7 +408,7 @@ def from_angle(cls, angle): def random_2D(cls): """Return a random 2D unit vector. """ - x, y = np.random.random(2) + x, y = 2 * (np.random.random(2) - 0.5) vec = cls(x, y) vec.normalize() return vec