33 #ifndef CUBBYFLOW_SAMPLERS_IMPL_H 34 #define CUBBYFLOW_SAMPLERS_IMPL_H 41 T cosAngle_2 = std::cos(angle / 2);
42 T y = 1 - (1 - cosAngle_2) * u1;
43 T r = std::sqrt(std::max<T>(0, 1 - y * y));
44 T phi =
static_cast<T
>(2.0 * PI<T>()) * u2;
45 T x = r * std::cos(phi);
46 T z = r * std::sin(phi);
49 return std::get<0>(ts) * x + axis * y + std::get<1>(ts) * z;
56 T r = std::sqrt(std::max<T>(0, 1 - y * y));
57 T phi =
static_cast<T
>(2.0 * PI<T>()) * u2;
58 T x = r * std::cos(phi);
59 T z = r * std::sin(phi);
62 return std::get<0>(ts) * x + normal * y + std::get<1>(ts) * z;
68 T phi =
static_cast<T
>(2.0 * PI<T>()) * u1;
70 T theta = std::acos(y);
71 T x = std::cos(phi) * std::sin(theta);
72 T z = std::sin(phi) * std::sin(theta);
76 return std::get<0>(ts) * x + normal * y + std::get<1>(ts) * z;
83 T r = std::sqrt(std::max<T>(0, 1 - y * y));
84 T phi =
static_cast<T
>(2.0 * PI<T>()) * u2;
85 T x = r * std::cos(phi);
86 T z = r * std::sin(phi);
95 T theta =
static_cast<T
>(2.0 * PI<T>()) * u2;
97 return Vector2<T>(r * std::cos(theta), r * std::sin(theta));
3-D vector class.
Definition: Vector3.h:26
Vector3< T > UniformSampleSphere(T u1, T u2)
Returns randomly a point on a sphere.
Definition: Samplers-Impl.h:80
Vector3< T > CosineWeightedSampleHemisphere(T u1, T u2, const Vector3< T > &normal)
Returns weighted sampled point on a hemisphere.
Definition: Samplers-Impl.h:66
Definition: pybind11Utils.h:24
std::tuple< Vector< T, 3 >, Vector< T, 3 > > Tangential() const
Returns the tangential vector for this vector.
Definition: Vector3-Impl.h:352
2-D vector class.
Definition: Vector2.h:26
Vector2< T > UniformSampleDisk(T u1, T u2)
Returns randomly a point on a disk.
Definition: Samplers-Impl.h:92
Vector3< T > UniformSampleCone(T u1, T u2, const Vector3< T > &axis, T angle)
Returns randomly sampled direction within a cone.
Definition: Samplers-Impl.h:39
Vector3< T > UniformSampleHemisphere(T u1, T u2, const Vector3< T > &normal)
Returns randomly sampled point within a unit hemisphere.
Definition: Samplers-Impl.h:53