-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrtweekend.h
More file actions
43 lines (33 loc) · 1.07 KB
/
rtweekend.h
File metadata and controls
43 lines (33 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef RTWEEKEND_H
#define RTWEEKEND_H
#include <memory>
#include <cmath>
#include <cstdlib>
#include <limits>
// Using
using std::shared_ptr;
using std::make_shared;
// Constants
const double pi = 3.14159265358979323846;
const double infinity = std::numeric_limits<double>::infinity(); // Representation of positive infinity, if available.
// Utilities
inline double degrees_to_radians(double degrees) {
return degrees * pi / 180;
}
inline double ffmin(double a, double b) { return a <= b ? a : b; } // choose min between a and b
inline double ffmax(double a, double b) { return a >= b ? a : b; } // choose max between a and b
inline double random_double() {
return rand() / (RAND_MAX + 1.0); // +1 because we want 0 <= rand < 1
}
inline double random_double(double min, double max) {
return min + random_double() * (max - min);
}
inline double clamp(double x, double min, double max) {
if (x > max) return max;
if (x < min) return min;
return x;
}
// Common headers
#include "ray.h"
#include "vec3.h"
#endif /* RTWEEKEND_H */