Precision controlΒΆ

In order to check if two points are the same, we have to set float numbers in limited digitals. By default, the package limits the float number at 10 digitals after zero, that is eps = 1e-10. We can change the setting with functions get_eps()/set_eps().

For instance

After eps has been set to 0.001, the point (0.1,0.2) euqals to point (0.100001, 0.200009) in the domain of Shape4D.

>>> get_eps()      # To get the current precision
1e-10

>>> set_eps(1e-2)  # To set precision to 10^-2
>>> get_eps()      # To see the result ...
0.01

The precision matters in geometry computation. As shown below, when the precision is set at 0.01, the function decides that a point is an internal one in a polygon, but it actually lies outsides.

P = (1.008, 1.005)
vertices = [(0.99, 0.99), (1,0.99), (1,1),(0.99,1)]  # To set a polygon
PointsInPolygon2D(P, vertices)      # To see if the point falls in the polygon.
>>>  True
_images/point_in_polygon2D.PNG