#include "math.h"

double math::random_double()
{
   // returns a random real in [0,1)
    return rand() / (RAND_MAX + 1.0);
}

double math::random_double(double min, double max)
{
    // returns a random real in [min,max)
    return min + (max-min)*math::random_double();
}

double math::degrees_to_radians(double degrees)
{
    return degrees * math::pi / 180;
}

double math::clamp(double x, double min, double max)
{
    if (x < min) return min;
    if (x > max) return max;
    return x;
}
