Wayverb
azimuth_elevation.h
1 #pragma once
2 
3 #include "utilities/aligned/vector.h"
4 
5 #include "glm/glm.hpp"
6 
7 #include <random>
8 
9 namespace wayverb {
10 namespace core {
11 
12 glm::vec3 sphere_point(double z, double theta);
13 glm::vec3 point_on_sphere(double az, double el);
14 
15 class direction_rng final {
16 public:
17  template <typename T>
18  direction_rng(T& engine)
19  : z(std::uniform_real_distribution<float>(-1, 1)(engine))
20  , theta(std::uniform_real_distribution<float>(-M_PI,
21  M_PI)(engine)) {}
22 
23  inline float get_z() const { return z; }
24  inline float get_theta() const { return theta; }
25 
26 private:
27  float z; // -1 to 1
28  float theta; // -M_PI to M_PI
29 };
30 
31 template<typename t>
32 glm::vec3 random_unit_vector(t& engine) {
33  const auto rng = direction_rng{engine};
34  return sphere_point(rng.get_z(), rng.get_theta());
35 }
36 
37 util::aligned::vector<glm::vec3> get_random_directions(size_t num);
38 
39 } // namespace core
40 } // namespace wayverb
Definition: traits.cpp:2
Definition: azimuth_elevation.h:15
Definition: capsule_base.h:9