From eefafefbae6a95ac1397dc0e9ecb3cde865b1f46 Mon Sep 17 00:00:00 2001 From: Carsten Hartenfels Date: Fri, 21 Sep 2018 20:03:28 +0200 Subject: [PATCH] Also add a load of other number constants These are all missing from standard C, so we might as well define em. See https://github.com/recp/cglm/pull/61#discussion_r219406859 --- include/cglm/types.h | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/include/cglm/types.h b/include/cglm/types.h index 72852e1..548965d 100644 --- a/include/cglm/types.h +++ b/include/cglm/types.h @@ -48,13 +48,33 @@ typedef CGLM_ALIGN_IF(16) vec4 mat4[4]; typedef vec4 versor; -#define GLM_PI 3.14159265358979323846264338327950288 -#define GLM_PI_2 1.57079632679489661923132169163975144 -#define GLM_PI_4 0.785398163397448309615660845819875721 +#define GLM_E 2.71828182845904523536028747135266250 /* e */ +#define GLM_LOG2E 1.44269504088896340735992468100189214 /* log2(e) */ +#define GLM_LOG10E 0.434294481903251827651128918916605082 /* log10(e) */ +#define GLM_LN2 0.693147180559945309417232121458176568 /* loge(2) */ +#define GLM_LN10 2.30258509299404568401799145468436421 /* loge(10) */ +#define GLM_PI 3.14159265358979323846264338327950288 /* pi */ +#define GLM_PI_2 1.57079632679489661923132169163975144 /* pi/2 */ +#define GLM_PI_4 0.785398163397448309615660845819875721 /* pi/4 */ +#define GLM_1_PI 0.318309886183790671537767526745028724 /* 1/pi */ +#define GLM_2_PI 0.636619772367581343075535053490057448 /* 2/pi */ +#define GLM_2_SQRTPI 1.12837916709551257389615890312154517 /* 2/sqrt(pi) */ +#define GLM_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */ +#define GLM_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */ -#define GLM_PIf ((float)GLM_PI) -#define GLM_PI_2f ((float)GLM_PI_2) -#define GLM_PI_4f ((float)GLM_PI_4) +#define GLM_Ef ((float) GLM_E) +#define GLM_LOG2Ef ((float) GLM_LOG2E) +#define GLM_LOG10Ef ((float) GLM_LOG10E) +#define GLM_LN2f ((float) GLM_LN2) +#define GLM_LN10f ((float) GLM_LN10) +#define GLM_PIf ((float) GLM_PI) +#define GLM_PI_2f ((float) GLM_PI_2) +#define GLM_PI_4f ((float) GLM_PI_4) +#define GLM_1_PIf ((float) GLM_1_PI) +#define GLM_2_PIf ((float) GLM_2_PI) +#define GLM_2_SQRTPIf ((float) GLM_2_SQRTPI) +#define GLM_SQRT2f ((float) GLM_SQRT2) +#define GLM_SQRT1_2f ((float) GLM_SQRT1_2) /* DEPRECATED! use GLM_PI and friends */ #define CGLM_PI GLM_PIf