-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrttutorial.h
More file actions
59 lines (42 loc) · 1.14 KB
/
rttutorial.h
File metadata and controls
59 lines (42 loc) · 1.14 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef RTTUTORIAL_H
#define RTTUTORIAL_H
#include <cmath>
#include <limits>
#include <memory>
#include <random>
#include <chrono>
// Usings
using std::shared_ptr;
using std::make_shared;
using std::sqrt;
// Constants
const double infinity = std::numeric_limits<double>::infinity();
const double pi = 3.1415926535897932385;
// Utility Functions
inline double clamp(double x, double min, double max) {
if (x < min) return min;
if (x > max) return max;
return x;
}
inline double degrees_to_radians(double degrees) {
return degrees * pi / 180.0;
}
inline double random_double(){
static std::random_device rd;
static std::mt19937 gen(rd());
static std::uniform_real_distribution<double> dis_double;
return dis_double(gen);
}
inline double random_double(double min, double max) {
return min + random_double()*(max - min);
}
inline int random_int(int min, int max) {
static std::random_device rd;
static std::mt19937 gen(rd());
static std::uniform_int_distribution<int> dis_int(min, max);
return dis_int(gen);
}
// Common Headers
#include "generals/ray.h"
#include "generals/vec3.h"
#endif //RTTUTORIAL_H