From 7ccabd7472822e91ef74db411ebe9b4d5caaa2a1 Mon Sep 17 00:00:00 2001 From: Ben Hambrecht Date: Tue, 10 Apr 2018 14:36:21 +0200 Subject: [PATCH] tweak to make the coin stacks more realistic --- active_projects/eop/chapter1.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/active_projects/eop/chapter1.py b/active_projects/eop/chapter1.py index fb230a41..2803bc6e 100644 --- a/active_projects/eop/chapter1.py +++ b/active_projects/eop/chapter1.py @@ -200,7 +200,12 @@ class FlatCoin(UprightCoin): # draw the ridges PI = TAU/2 - ridge_angles = np.arange(PI/self.nb_ridges,PI,PI/self.nb_ridges) + dtheta = PI/self.nb_ridges + ridge_angles = np.arange(dtheta,PI,dtheta) + # add a twist onto each coin + ridge_angles += np.random.rand(1) * dtheta + # crop the angles that overshoot on either side + ridge_angles = ridge_angles[(ridge_angles > 0) * (ridge_angles < PI)] ridge_positions = 0.5 * 2 * self.radius * np.array([ np.cos(theta) for theta in ridge_angles ])