GSoC/GCI Archive
Google Code-in 2012 BRL-CAD

Convert NEAR_ZERO() macro calls to NEAR_EQUAL() and EQUAL()

completed by: javamonn

mentors: Sean

BRL-CAD's math library provides two macros, NEAR_ZERO() and NEAR_EQUAL() that test whether a number is approximately "0" or whether two numbers are approximately equal to each other.  The numbers are "approximately" zero or equal based on a specified tolerance value.  We recently added new macros that simplify caller use, but they need to be propagated throughout the code.  NEAR_ZERO() has existed for a LOT longer than NEAR_EQUAL() and EQUAL() so code needs to be updated.

This task involves going through and reviewing all calls to NEAR_ZERO() and for cases where there's a subtraction of two numbers occurring, the call gets converted to a NEAR_EQUAL() or EQUAL() comparison.  It's only the latter if the tolerance is SMALL_FASTF and is undocumented.  IF there is a comment nearby that mentions the tolerance, you're going to only convert it to NEAR_EQUAL() and retain the tolerance.

Submit your work as a single patch file against our latest SVN sources with all changes included.  See http://brlcad.org/wiki/Deuces to get started and help making patches.