Commit 04a4a161 authored by lode_leroy's avatar lode_leroy

fix bug in torus-point intersection

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@44 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 737be2a4
...@@ -66,7 +66,7 @@ def intersect_cylinder_line(center, axis, radius, radiussq, direction, edge): ...@@ -66,7 +66,7 @@ def intersect_cylinder_line(center, axis, radius, radiussq, direction, edge):
# take a plane throught the line and along the cylinder axis (1) # take a plane throught the line and along the cylinder axis (1)
n = d.cross(axis) n = d.cross(axis)
if n.normsq()==0: if n.normsq()==0:
# no contact point, but should check here if torus *always* intersects line... # no contact point, but should check here if cylinder *always* intersects line...
return (None,None,INFINITE) return (None,None,INFINITE)
n.normalize() n.normalize()
# the contact line between the cylinder and this plane (1) # the contact line between the cylinder and this plane (1)
...@@ -79,7 +79,7 @@ def intersect_cylinder_line(center, axis, radius, radiussq, direction, edge): ...@@ -79,7 +79,7 @@ def intersect_cylinder_line(center, axis, radius, radiussq, direction, edge):
# now extrude the contact line along the direction, this is a plane (2) # now extrude the contact line along the direction, this is a plane (2)
n2 = direction.cross(axis) n2 = direction.cross(axis)
if n2.normsq()==0: if n2.normsq()==0:
# no contact point, but should check here if torus *always* intersects line... # no contact point, but should check here if cylinder *always* intersects line...
return (None,None,INFINITE) return (None,None,INFINITE)
n2.normalize() n2.normalize()
p = Plane(ccl, n2) p = Plane(ccl, n2)
...@@ -284,12 +284,12 @@ def intersect_torus_point(center, axis, majorradius, minorradius, majorradiussq, ...@@ -284,12 +284,12 @@ def intersect_torus_point(center, axis, majorradius, minorradius, majorradiussq,
if (l_sq<minlsq) or (l_sq>maxlsq): if (l_sq<minlsq) or (l_sq>maxlsq):
return (None,None,INFINITE) return (None,None,INFINITE)
l = sqrt(l_sq) l = sqrt(l_sq)
z_sq = minorradiussq - sqr(majorradiussq - l) z_sq = minorradiussq - sqr(majorradius - l)
if z_sq < 0: if z_sq < 0:
return (None,None,INFINITE) return (None,None,INFINITE)
z = sqrt(z_sq) z = sqrt(z_sq)
ccp=Point(point.x,point.y,center.z-z) ccp=Point(point.x,point.y,center.z-z)
dist = center.z-z dist = ccp.z-point.z
elif direction.z==0: # push elif direction.z==0: # push
z = point.z - center.z z = point.z - center.z
if z<-minorradius or z>minorradius: if z<-minorradius or z>minorradius:
......
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