From 4402ae054e5d52d3b975045c9520f8ff7d28934b Mon Sep 17 00:00:00 2001 From: Darshan Bhanushali Date: Sat, 9 Jun 2018 01:38:05 -0400 Subject: [PATCH] updating trilateration.py to avoid divide by zero error for case with xA= 0 yA = 0 zA=2.7 xB = 5 yB = 0 zB = 2.7 xC = 2.5 yC = -5 zC = 5 we get divide by zero error for A and E variable on line 61 because C becomes zero. Hence the try block. --- trilaterate.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/trilaterate.py b/trilaterate.py index 9976c58..b45f1ae 100644 --- a/trilaterate.py +++ b/trilaterate.py @@ -58,8 +58,14 @@ def getlocation(xA,yA,zA,xB,yB,zB,xC,yC,zC): E-=B E-=D A=-A - E=E/float(C) - A=A/float(C) + try: + E=E/float(C) + except: + E = 0 + try: + A=A/float(C) + except: + A = 0 print "y1",A, E