37 lines
655 B
C++
37 lines
655 B
C++
#ifndef RTWEEKEND_H
|
|
#define RTWEEKEND_H
|
|
|
|
#include <math.h>
|
|
#include <memory>
|
|
|
|
/* Utility functions */
|
|
double degrees_to_radians(double d)
|
|
{
|
|
return d * M_PI / 180;
|
|
}
|
|
|
|
/* Returns a double in the range [0,1) */
|
|
inline double random_double()
|
|
{
|
|
return rand() / RAND_MAX + 1.0;
|
|
}
|
|
|
|
/* Returns a double in the range [min,max) */
|
|
inline double random_double(double min, double max)
|
|
{
|
|
return min + (max-min) * random_double();
|
|
}
|
|
|
|
/* Clamps a value between [min,max] */
|
|
inline double clamp(double v, double min, double max)
|
|
{
|
|
return v < min ? min : v > max ? max : v;
|
|
}
|
|
|
|
/* Common internal headers */
|
|
|
|
#include "ray.hpp"
|
|
#include "vec3.hpp"
|
|
|
|
|
|
#endif
|