GouMinghao / Geometry3D

Geometry3D: 3D Computational Geometrics Library
GNU General Public License v3.0
88 stars 23 forks source link

intersection of convex polygons sometime works fine and sometime fails #10

Closed kleinerl closed 2 years ago

kleinerl commented 2 years ago

Hi Thank you for the beautiful library.

When I run this code: from Geometry3D import *

poly1=Sphere(Point(15.592607258702628, -66.15776443481445, 32.0),10,n1=7,n2=3) poly2=Cylinder(Point(229.78870794537943, -64.86530276807025, 32.0),10,Vector(Point(229.78870794537943, -64.86530276807025, 32.0),Point(214.4889864671277, -64.95762145752087, 32.0)),10)

print(intersection(poly1,poly2))

I get the following output options:

It's strange, but the geometrical objects not even close: Figure_1

Please, help

GouMinghao commented 2 years ago

Thank you for your bug report, this is a problem of floating point precision. A quick fix would be add set_eps(1e-5) after importing Geometry3D.

This problem will be fixed in future version.