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,25 +16,24 @@ def intersect_lines(xl,zl,nxl,nzl,xm,zm,nxm,nzm): ...@@ -16,25 +16,24 @@ 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
if isZero(nzl) and isZero(nzm): try:
pass if isZero(nzl) and isZero(nzm):
elif isZero(nzl) or isZero(nxl):
X = xl
Z = zm + (xm-xl)*nxm/nzm
return (X,Z)
elif isZero(nzm) or isZero(nxm):
X = xm
Z = zl - (xm-xl)*nxl/nzl
return (X,Z)
else:
try:
X = (zl-zm+(xm*nxm/nzm-xl*nxl/nzl))/(nxm/nzm-nxl/nzl)
except:
pass pass
elif isZero(nzl) or isZero(nxl):
if X and xl < X and X < xm: X = xl
Z = zl + (X-xl)*nxl/nzl Z = zm + (xm-xl)*nxm/nzm
return (X,Z) return (X,Z)
elif isZero(nzm) or isZero(nxm):
X = xm
Z = zl - (xm-xl)*nxl/nzl
return (X,Z)
else:
X = (zl-zm+(xm*nxm/nzm-xl*nxl/nzl))/(nxm/nzm-nxl/nzl)
if X and xl < X and X < xm:
Z = zl + (X-xl)*nxl/nzl
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