20 static thread_local std::mt19937 generator(std::random_device{}());
21 static thread_local std::uniform_real_distribution<float> unit(0.0f, 1.0f);
23 const float r = std::sqrt(unit(generator));
24 const float theta = unit(generator) * 2.0f * std::numbers::pi_v<float>;
25 point =
Vector2(r * std::cos(theta), r * std::sin(theta));
30 constexpr float goldenAngle = 2.39996322972865332f;
31 const float theta =
static_cast<float>(index) * goldenAngle;
32 const float r = std::sqrt(
static_cast<float>(index) /
static_cast<float>(numPoints));
33 point =
Vector2(r * std::cos(theta), r * std::sin(theta));
37 float start = 0.0f,
float end = 1.0f)
39 constexpr float goldenAngle = 2.39996322972865332f;
40 start = 1.0f - 2.0f * start;
41 end = 1.0f - 2.0f * end;
43 const float y = start + (end - start) * (
static_cast<float>(index) /
static_cast<float>(numPoints));
44 const float radius = std::sqrt(std::max(0.0f, 1.0f - y * y));
45 const float theta = goldenAngle *
static_cast<float>(index);
47 point =
Vector3(std::cos(theta) * radius, y, std::sin(theta) * radius);
52 uint32_t bits = (i << 16u) | (i >> 16u);
53 bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
54 bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
55 bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
56 bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
57 return static_cast<float>(
static_cast<double>(bits) * 2.3283064365386963e-10);
static void circlePointDeterministic(Vector2 &point, const int index, const int numPoints)
static void circlePoint(Vector2 &point)
static float radicalInverse(uint32_t i)
static void spherePointDeterministic(Vector3 &point, const int index, const int numPoints, float start=0.0f, float end=1.0f)
2D vector for UV coordinates, screen positions, and 2D math.
3D vector for positions, directions, and normals with multi-backend SIMD acceleration.