bellockk / alphashape

Toolbox for constructing alpha shapes.
MIT License
258 stars 28 forks source link

Fix ValueError: math domain error bug when area of triangle is zero. #10

Closed ngodber closed 4 years ago

ngodber commented 4 years ago

Hey,

Ran into a bug where I would get a ValueError: math domain error when triangle area are approaching zero. My guess is that precision error as the area of the triangle approaches zero meant that s * (s-a)(s-b)(s-c) was evaluating to tiny negative value? Moving the positivity check before the square root fixed the problem. Figured I'd PR the fix so that it can make it back into the main repo.

Cheers for the work putting this together.

Cheers, Neil

codecov-io commented 4 years ago

Codecov Report

Merging #10 into master will increase coverage by 0.23%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #10      +/-   ##
==========================================
+ Coverage   73.63%   73.87%   +0.23%     
==========================================
  Files           9        9              
  Lines         220      222       +2     
==========================================
+ Hits          162      164       +2     
  Misses         58       58
Impacted Files Coverage Δ
alphashape/alphashape.py 83.33% <100%> (+0.57%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0a6cbbc...31c4ccd. Read the comment docs.