pboyer / verb

Open-source, cross-platform NURBS
http://www.verbnurbs.com
MIT License
733 stars 106 forks source link

Error when trying to intersect 2 Spheres (Python) #42

Open henryJack opened 6 years ago

henryJack commented 6 years ago

I'm using the python version of verb. It seems to work great (although the whole module being compiled into on file is a little weird) However, I've got an issue when trying to intersect two spheres. If you run the following...

from build.verb import verb_geom_Intersect as Intersect
from build.verb import verb_geom_SphericalSurface as SphericalSurface

sphere_1 = SphericalSurface(center=[1, 2, 3], radius=5)
sphere_2 = SphericalSurface(center=[1, 2, 4], radius=5)

result = Intersect.surfaces(sphere_1, sphere_2)

You get the following error...

verb 2.1.0
Traceback (most recent call last):
  File "C:/dev/verb/build/intersection_example.py", line 121, in <module>
    result = Intersect.surfaces(srf1, srf2, 1e-6)
  File "C:\dev\verb\build\verb.py", line 10121, in surfaces
    return _hx_local_1()
  File "C:\dev\verb\build\verb.py", line 10120, in _hx_local_1
    return list(map(_hx_local_0,verb_eval_Intersect.surfaces(first.asNurbs(),second.asNurbs(),tol)))
  File "C:\dev\verb\build\verb.py", line 7085, in surfaces
    tess1 = verb_eval_Tess.rationalSurfaceAdaptive(surface0)
  File "C:\dev\verb\build\verb.py", line 9025, in rationalSurfaceAdaptive
    arrTrees = verb_eval_Tess.divideRationalSurfaceAdaptive(surface,options)
  File "C:\dev\verb\build\verb.py", line 8947, in divideRationalSurfaceAdaptive
    norm = verb_core_Vec.normalized(verb_core_Vec.cross(python_internal_ArrayImpl._get((ds[0] if 0 < len(ds) else None), 1),python_internal_ArrayImpl._get((ds[1] if 1 < len(ds) else None), 0)))
  File "C:\dev\verb\build\verb.py", line 5408, in normalized
    return verb_core_Vec.div(arr,verb_core_Vec.norm(arr))
  File "C:\dev\verb\build\verb.py", line 5603, in div
    _g.append(((a[i] if i >= 0 and i < len(a) else None) / b))
ZeroDivisionError: float division by zero

Any Ideas?