From e157ee61e63fdaae85ecd51dd7f0daff68109f69 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Sun, 4 Aug 2019 22:58:41 -0700 Subject: [PATCH] Add docs for the math package. --- include/wrmath/math.h | 43 +++++++++++++++++++++++++++++++++++++------ src/math.cc | 4 ++++ 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/include/wrmath/math.h b/include/wrmath/math.h index a1da156..b88fc3b 100644 --- a/include/wrmath/math.h +++ b/include/wrmath/math.h @@ -12,22 +12,53 @@ namespace math { /** * Convert radians to degrees. * @param rads the angle in radians - * @return the angle in degrees, + * @return the angle in degrees. */ float RadiansToDegreesF(float rads); + +/** + * Convert radians to degrees. + * @param rads the angle in radians + * @return the angle in degrees. + */ double RadiansToDegreesD(double rads); + +/** + * Convert degrees to radians. + * @param degrees the angle in degrees + * @return the angle in radians. + */ float DegreesToRadiansF(float degrees); + +/** + * Convert degrees to radians. + * @param degrees the angle in degrees + * @return the angle in radians. + */ double DegreesToRadiansD(double degrees); - -const double Epsilon_double = 0.0001; -const float Epsilon_float = 0.0001; - - +/** + * Get the default epsilon value. + * @param epsilon The variable to store the epsilon value in. + */ void DefaultEpsilon(double &epsilon); + +/** + * Get the default epsilon value. + * @param epsilon The variable to store the epsilon value in. + */ void DefaultEpsilon(float &epsilon); + +/** + * Return whether the two values of type T are equal to within some tolerance. + * @tparam T The type of value + * @param a A value of type T used as the left-hand side of an equality check. + * @param b A value of type T used as the right-hand side of an equality check. + * @param epsilon The tolerance value. + * @return Whether the two values are "close enough" to be considered equal. + */ template static T WithinTolerance(T a, T b, T epsilon) diff --git a/src/math.cc b/src/math.cc index 3d6d2b3..3deea7b 100644 --- a/src/math.cc +++ b/src/math.cc @@ -33,6 +33,10 @@ DegreesToRadiansD(double degrees) } +const double Epsilon_double = 0.0001; +const float Epsilon_float = 0.0001; + + void DefaultEpsilon(double &epsilon) {