From 9706816fe43a7b494540d59c1fd063e358775b6c Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Sat, 1 Feb 2020 13:59:30 +0100 Subject: [PATCH] gears: prevent division by zero --- boxes/gears.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boxes/gears.py b/boxes/gears.py index c17659d..ccfa844 100644 --- a/boxes/gears.py +++ b/boxes/gears.py @@ -78,14 +78,14 @@ def undercut_min_teeth(pitch_angle, k=1.0): The return value should be rounded upwards for perfect safety. E.g. min_teeth = int(math.ceil(undercut_min_teeth(20.0))) # 18, not 17 """ - x = sin(radians(pitch_angle)) + x = max(sin(radians(pitch_angle)), 0.01) return 2*k /(x*x) def undercut_max_k(teeth, pitch_angle=20.0): """ computes the maximum k value for a given teeth count and pitch_angle so that no undercut occurs. """ - x = sin(radians(pitch_angle)) + x = max(sin(radians(pitch_angle)), 0.01) return 0.5 * teeth * x * x def undercut_min_angle(teeth, k=1.0):