Commit c3685f3e authored by lode_leroy's avatar lode_leroy

guard against float division

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@22 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 4b8afbdc
...@@ -16,6 +16,7 @@ def intersect_lines(xl,zl,nxl,nzl,xm,zm,nxm,nzm): ...@@ -16,6 +16,7 @@ def intersect_lines(xl,zl,nxl,nzl,xm,zm,nxm,nzm):
X = None X = None
Z = None Z = None
# print "xl=",xl,", zl=",zl,"nxl=",nxl,", nzl=",nzl,", X=", X, ", Z=",Z,", xm=",xm,",zm=",zm, ", nxm=",nxm,",nzm=",nzm # print "xl=",xl,", zl=",zl,"nxl=",nxl,", nzl=",nzl,", X=", X, ", Z=",Z,", xm=",xm,",zm=",zm, ", nxm=",nxm,",nzm=",nzm
try:
if isZero(nzl) and isZero(nzm): if isZero(nzl) and isZero(nzm):
pass pass
elif isZero(nzl) or isZero(nxl): elif isZero(nzl) or isZero(nxl):
...@@ -27,14 +28,12 @@ def intersect_lines(xl,zl,nxl,nzl,xm,zm,nxm,nzm): ...@@ -27,14 +28,12 @@ def intersect_lines(xl,zl,nxl,nzl,xm,zm,nxm,nzm):
Z = zl - (xm-xl)*nxl/nzl Z = zl - (xm-xl)*nxl/nzl
return (X,Z) return (X,Z)
else: else:
try:
X = (zl-zm+(xm*nxm/nzm-xl*nxl/nzl))/(nxm/nzm-nxl/nzl) X = (zl-zm+(xm*nxm/nzm-xl*nxl/nzl))/(nxm/nzm-nxl/nzl)
except:
pass
if X and xl < X and X < xm: if X and xl < X and X < xm:
Z = zl + (X-xl)*nxl/nzl Z = zl + (X-xl)*nxl/nzl
return (X,Z) return (X,Z)
except:
pass
return (None,None) return (None,None)
def intersect_plane_point(plane, direction, point): def intersect_plane_point(plane, direction, point):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment