Go to the documentation of this file.
12 #include <glm/gtc/matrix_transform.hpp>
13 #include <glm/gtx/norm.hpp>
14 #include <glm/gtx/quaternion.hpp>
15 #include <glm/gtc/epsilon.hpp>
31 extern std::ostream&
operator<<(std::ostream& o,
const glm::mat4& m);
40 extern std::ostream&
operator<<(std::ostream& o,
const glm::mat3& m);
49 extern std::ostream&
operator<<(std::ostream& o,
const glm::vec3& v);
58 extern std::ostream&
operator<<(std::ostream& o,
const glm::vec4& v);
67 extern std::ostream&
operator<<(std::ostream& o,
const glm::vec2& v);
77 extern std::ostream&
operator<<(std::ostream& o,
const glm::quat& v);
80 using point3 = glm::vec3;
81 using color = glm::vec3;
84 const float kPI = glm::pi<float>();
85 const float kINFINITY = std::numeric_limits<float>::infinity();
93 static std::uniform_real_distribution<float> distribution(0.0f, 1.0f);
94 static std::mt19937 generator;
95 return distribution(generator);
101 inline float random(
float min,
float max) {
102 static std::uniform_real_distribution<float> distribution(min, max);
103 static std::mt19937 generator;
104 return distribution(generator);
111 float x =
random(-0.5, 0.5);
112 float y =
random(-0.5, 0.5);
113 float z =
random(-0.5, 0.5);
114 return glm::vec3(x, y, z);
121 float x =
random(-0.5, 0.5);
122 float y =
random(-0.5, 0.5);
123 return glm::vec3(x, y, 0);
132 while (glm::length(p) >= 1.0f) {
143 while (glm::length(p) >= 1.0f) {
158 if (glm::dot(in_unit_sphere, normal) > 0.0f) {
159 return in_unit_sphere;
161 return -in_unit_sphere;
175 #endif // AGL_AGLM_H_
glm::vec3 randomUnitSquare()
Return a random direction in a unit square in the XY plane.
Definition: aglm.h:120
glm::vec3 randomHemisphere(const glm::vec3 &normal)
Generate random direction in hemisphere around normal.
Definition: aglm.h:154
glm::vec3 randomUnitDisk()
Return a random direction in a unit disk in the XY plane.
Definition: aglm.h:141
glm::vec3 randomUnitVector()
Generate random unit vector.
Definition: aglm.h:170
std::ostream & operator<<(std::ostream &o, const glm::mat4 &m)
Print a matrix.
Definition: aglm.cpp:9
glm::vec3 randomUnitCube()
Return a random direction in a unit cube.
Definition: aglm.h:110
float random()
Return a random number between 0 and 1 [0, 1)
Definition: aglm.h:92
glm::vec3 randomUnitSphere()
Return a random direction in a unit sphere.
Definition: aglm.h:130