5#include <Common/assertion.h>
65 PH_ASSERT_GE(radius, T(0));
77 PH_ASSERT_LE(T(0), sample[0]); PH_ASSERT_LE(sample[0], T(1));
78 PH_ASSERT_LE(T(0), sample[1]); PH_ASSERT_LE(sample[1], T(1));
81 const T yValue = sample[1];
82 const T yRadius = std::sqrt(T(1) - yValue * yValue);
85 std::sin(phi) * yRadius,
87 std::cos(phi) * yRadius);
89 return localUnitPos.mul(m_radius);
94 const std::array<T, 2>& sample, T*
const out_pdfA)
const
98 *out_pdfA = T(1) / getArea();
100 return sampleToSurfaceArchimedes(sample);
106 PH_ASSERT_LE(
static_cast<T
>(0), sample[0]); PH_ASSERT_LE(sample[0],
static_cast<T
>(1));
107 PH_ASSERT_LE(
static_cast<T
>(0), sample[1]); PH_ASSERT_LE(sample[1],
static_cast<T
>(1));
110 const T yValue = std::sqrt(sample[1]);
111 const T yRadius = std::sqrt(
static_cast<T
>(1) - yValue * yValue);
114 std::sin(phi) * yRadius,
116 std::cos(phi) * yRadius);
118 return localUnitPos.mul(m_radius);
123 const std::array<T, 2>& sample, T*
const out_pdfA)
const
125 const auto localPos = sampleToSurfaceCosThetaWeighted(sample);
127 PH_ASSERT_GE(localPos.y(),
static_cast<T
>(0));
128 const T cosTheta = localPos.y() / m_radius;
139 const std::array<T, 2>& sample,
const T exponent)
const
141 PH_ASSERT_LE(
static_cast<T
>(0), sample[0]); PH_ASSERT_LE(sample[0],
static_cast<T
>(1));
142 PH_ASSERT_LE(
static_cast<T
>(0), sample[1]); PH_ASSERT_LE(sample[1],
static_cast<T
>(1));
145 const T cosTheta = std::pow(sample[1],
static_cast<T
>(1) / (exponent +
static_cast<T
>(1)));
146 const T sinTheta = std::sqrt(
static_cast<T
>(1) - cosTheta * cosTheta);
149 std::sin(phi) * sinTheta,
151 std::cos(phi) * sinTheta);
153 return localUnitPos.mul(m_radius);
158 const std::array<T, 2>& sample,
const T exponent, T*
const out_pdfA)
const
160 const auto localPos = sampleToSurfaceCosLobeWeighted(exponent, sample);
162 PH_ASSERT_GE(localPos.y,
static_cast<T
>(0));
163 const T cosTheta = localPos.y / m_radius;
168 *out_pdfA /= m_radius * m_radius;
A hemisphere in 3-D space.
Definition THemisphere.h:21
TVector3< T > sampleToSurfaceCosLobeWeighted(const std::array< T, 2 > &sample, T exponent) const
Definition THemisphere.h:138
TVector3< T > sampleToSurfaceCosThetaWeighted(const std::array< T, 2 > &sample) const
Definition THemisphere.h:104
static THemisphere makeUnit()
Definition THemisphere.h:56
T getArea() const
The area of the dome part.
Definition THemisphere.h:69
TVector3< T > sampleToSurfaceArchimedes(const std::array< T, 2 > &sample) const
Map the 2D sample to a position on the surface of the hemisphere.
Definition THemisphere.h:75
Represents a 3-D vector.
Definition TVector3.h:17
constexpr T rcp_two_pi
Value of .
Definition constant.h:33
constexpr T two_pi
Value of .
Definition constant.h:27
constexpr T pi
Value of .
Definition constant.h:15
Math functions and utilities.
Definition TransformInfo.h:10