NanoComp / libctl

Guile-based library implementing flexible control files for scientific simulations
GNU General Public License v2.0
19 stars 22 forks source link

WIP: refine point_in_prism to handle points on prism faces more carefully #23

Closed HomerReid closed 6 years ago

HomerReid commented 6 years ago

Introduce a more systematic strategy for adjudicating geometric questions involving (a) points lying precisely on polygon edges or prism faces, (b) the degenerate case of line/line intersection in the case where the lines are exactly or nearly parallel.

With this revision, the default convention is to consider points lying on polygon edges or prism faces to be inside the polygon/prism. However, this convention may be reversed by setting the environment variable LIBCTL_EXCLUDE_BOUNDARIES=1, in which case points on edges/faces are not considered interior points.

With this update, the test-prism unit test needed to be updated----it seems the legacy point_in_object implementation for blocks make somewhat arbitrary decisions about whether points on boundaries are interior points. This was causing mismatches with the new point_in_prism implementation, which makes more consistent decisions. In the updated test, if the results of point_in_block and point_in_prism disagree for a given point, the point_in_prism test is repeated with the sense of the boundary-point exclusion inverted (i.e. if points on prism faces were considered interior before, they are considered exterior now). This update eliminates all mismatches with the point_in_block code, so the unit test is passing again.