-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtweekend.h
45 lines (33 loc) · 846 Bytes
/
rtweekend.h
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
#pragma once
#include <cmath>
#include <limits>
#include <memory>
#include <cstdlib>
// 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 degrees_to_radians(double degrees) {
return degrees * pi / 180.0;
}
// Returns a random real in [0,1]
inline double random_double() {
return rand() / (RAND_MAX + 1.0);
}
// Returns a random real in [min,max]
inline double random_double(double min, double max) {
return min + (max-min)*random_double();
}
// Clamps values to [min,max]
inline double clamp(double x, double min, double max) {
if ( x < min ) return min;
if ( x > max ) return max;
return x;
}
// Common headers
#include "ray.h"
#include "vec3.h"