Shkyera Engine
Easy to use, game engine for Python
Loading...
Searching...
No Matches
Random.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <glm/glm.hpp>
4#include <limits>
5#include <random>
6#include <vector>
7
8namespace shkyera::random {
9
10template <typename SampledType>
11class Uniform {
12 public:
14
16
17 private:
18 std::mt19937_64 _rng;
19 std::uniform_real_distribution<SampledType> _dist;
20};
21
22template <typename SampledType>
23class Normal {
24 public:
26
27 double operator()() { return _dist(_rng); }
28
29 private:
30 std::mt19937_64 _rng;
31 std::normal_distribution<SampledType> _dist;
32};
33
34class Sphere {
35 public:
36 Sphere() : _uniformSampler(-1.0f, 1.0f), _rng(std::random_device{}()) {}
37
38 glm::vec3 operator()() {
39 glm::vec3 point;
40
44
45 return glm::normalize(point);
46 }
47
48 private:
50 std::mt19937_64 _rng;
51};
52
53} // namespace shkyera::random
Definition Random.hpp:23
std::mt19937_64 _rng
Definition Random.hpp:30
std::normal_distribution< SampledType > _dist
Definition Random.hpp:31
double operator()()
Definition Random.hpp:27
Normal(SampledType mean, SampledType stddev)
Definition Random.hpp:25
Definition Random.hpp:34
std::mt19937_64 _rng
Definition Random.hpp:50
glm::vec3 operator()()
Definition Random.hpp:38
Uniform< float > _uniformSampler
Definition Random.hpp:49
Sphere()
Definition Random.hpp:36
Definition Random.hpp:11
std::uniform_real_distribution< SampledType > _dist
Definition Random.hpp:19
Uniform(SampledType min, SampledType max)
Definition Random.hpp:13
std::mt19937_64 _rng
Definition Random.hpp:18
SampledType operator()()
Definition Random.hpp:15
Definition Random.cpp:3
Definition Mesh.cpp:16
Definition Clock.hpp:9