From 2c2bb0426ceff2ddc9284b506102b967d768dadf Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 25 May 2011 17:50:51 +0200 Subject: PR gradient check --- src/utils.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/utils.h') diff --git a/src/utils.h b/src/utils.h index 4433023f..a11cd59e 100644 --- a/src/utils.h +++ b/src/utils.h @@ -140,6 +140,13 @@ static inline double angle_between(double x1, double y1, double z1, return acos(cosine); } +static inline int within_tolerance(double a, double b, double percent) +{ + double tol = a * (percent/100.0); + if ( fabs(b-a) < fabs(tol) ) return 1; + return 0; +} + /* ----------------------------- Useful macros ------------------------------ */ -- cgit v1.2.3