-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Description
These are definetely evil:
#ifndef PI
#define PI 3.14159265358979323846
#endif
#ifndef TWO_PI
#define TWO_PI 6.28318530717958647693
#endif
#ifndef M_TWO_PI
#define M_TWO_PI 6.28318530717958647693
#endif
#ifndef FOUR_PI
#define FOUR_PI 12.56637061435917295385
#endif
#ifndef HALF_PI
#define HALF_PI 1.57079632679489661923
#endif
#ifndef DEG_TO_RAD
#define DEG_TO_RAD (PI/180.0)
#endif
#ifndef RAD_TO_DEG
#define RAD_TO_DEG (180.0/PI)
#endif
#ifndef MIN
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
#endif
#ifndef MAX
#define MAX(x,y) (((x) > (y)) ? (x) : (y))
#endif
#ifndef CLAMP
#define CLAMP(val,min,max) ((val) < (min) ? (min) : ((val > max) ? (max) : (val)))
#endif
#ifndef ABS
#define ABS(x) (((x) < 0) ? -(x) : (x))
#endifSuggestions
PI- I suggest a
constexprvalue withM_PI.
- I suggest a
TWO_PI- Trivial change.
M_TWO_PI- Trivial change.
FOUR_PI- Trivial change.
HALF_PI- Trivial change.
DEG_TO_RAD- This should be a
constexprfunction.
- This should be a
RAD_TO_DEG- This should be a
constexprfunction.
- This should be a
MIN- This should use
std::min().
- This should use
MAX- This should use
std::max().
- This should use
CLAMP- This should be a
constexprfunction.
- This should be a
ABS- This should use
std::abs. - We need a float version which uses
std::fabstoo.
- This should use