diff --git a/practical_work/vec2/util.c b/practical_work/vec2/util.c new file mode 100644 index 0000000000000000000000000000000000000000..a9884e272340aa1eb2fe5e04e66a2415a51bc517 --- /dev/null +++ b/practical_work/vec2/util.c @@ -0,0 +1,9 @@ +#include <stdlib.h> +#include "util.h" + +double rand_to_range(double x0, double x1) { + double delta = x1 - x0; + double rescaled = (double)rand() / RAND_MAX * delta + x0; + + return rescaled; +} diff --git a/practical_work/vec2/util.h b/practical_work/vec2/util.h new file mode 100644 index 0000000000000000000000000000000000000000..3e228d828bdd684b1c089bd0a7ac3623cc9c5fd6 --- /dev/null +++ b/practical_work/vec2/util.h @@ -0,0 +1,6 @@ +#ifndef _UTIL_H_ +#define _UTIL_H_ + +double rand_to_range(double x0, double x1); + +#endif