srp
software rendering pipeline
Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1// Software Rendering Pipeline (SRP) library
2// Licensed under GNU GPLv3
3
11#pragma once
12
13#define _USE_MATH_DEFINES
14#include <math.h>
15
16#ifndef M_PI
17 #define M_PI 3.14159265358979323846
18#endif
19
21#define MIN(a, b) ( (a) > (b) ? (b) : (a) )
23#define MAX(a, b) ( (a) > (b) ? (a) : (b) )
24
29#define CLAMP(min, max, value) \
30 ( \
31 (value < min) ? \
32 (min) : \
33 (value > max) ? \
34 (max) : \
35 (value) \
36 )
37
39#define FRACTIONAL(x) ( (x) - floor(x) )
40
41#define EPSILON 1e-9
43#define ROUGHLY_EQUAL(a, b) (fabs((a) - (b)) <= EPSILON)
45#define ROUGHLY_ZERO(x) (fabs(x) <= EPSILON)
46
48#define ROUGHLY_LESS_OR_EQUAL(a, b) ((a) <= (b) + EPSILON)
50#define ROUGHLY_GREATER_OR_EQUAL(a, b) ((a) >= (b) - EPSILON)
51
// ingroup Math_internal