Skip to content
Snippets Groups Projects
Commit ab2182d5 authored by Yoel's avatar Yoel
Browse files

New files Random, which include the rand-stuff prev. in material

parent 97cd5a63
No related branches found
No related tags found
No related merge requests found
#include "Random.h"
namespace util {
Vec3 rand_vec3() {
return Vec3(dis(gen), dis(gen), dis(gen));
}
bool in_circle(const Vec3& v) {
return v.length() <= 1;
}
Vec3 rand_vec3_in_circle(float r) {
Vec3 result;
do {
result = rand_vec3();
} while (!in_circle(result));
return result * r;
}
} // namespace util
\ No newline at end of file
#pragma once
#include <random>
#include "Vec3.h"
namespace util {
static std::random_device rd;
static std::mt19937 gen(rd());
static std::uniform_real_distribution<> dis(-1.0, 1.0);
Vec3 rand_vec3();
bool in_circle(const Vec3& v);
Vec3 rand_vec3_in_circle(float r);
} // namespace util
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment