sgsellan / gpytoolbox

A collection of utility functions to prototype geometry processing research in python
https://gpytoolbox.org
GNU General Public License v3.0
196 stars 16 forks source link

NaNs in the double areas #119

Closed odedstein closed 4 months ago

odedstein commented 5 months ago

Our doublearea_instrinsic currently contains

dblA = 0.5 * np.sqrt((a+(b+c)) * (c-(a-b)) * (c+(a-b)) * (a+(b-c)))

If the areas are very small, this can NaN. Ideally, we would do

arg = (a+(b+c)) * (c-(a-b)) * (c+(a-b)) * (a+(b-c))
dblA = 0.5 * np.sqrt(np.maximum(arg, 0.))

However, if I make this change, the unit test for reach_for_the_spheres fails. I speculate that it is because the optimization in reach_for_the_spheres does not terminate as early anymore, so it reaches a later stage where it can crash.

What should be done about it?