vMF sampling simplification suggested by Stephen Hill

metadata
Wenzel Jakob 2015-06-28 18:53:32 +02:00
parent d24f953c14
commit 742400485d
1 changed files with 2 additions and 7 deletions

View File

@ -45,13 +45,8 @@ Vector VonMisesFisherDistr::sample(const Point2 &sample) const {
sample.x * std::sinh(m_kappa)) / m_kappa; sample.x * std::sinh(m_kappa)) / m_kappa;
#else #else
/* Numerically stable version */ /* Numerically stable version */
Float cosTheta; Float cosTheta = 1 + (math::fastlog(sample.x +
if (sample.x > 0) { math::fastexp(-2 * m_kappa) * (1 - sample.x))) / m_kappa;
cosTheta = 1 + (math::fastlog(sample.x) + math::fastlog(
1 - math::fastexp(-2*m_kappa) * ((sample.x-1) / sample.x))) / m_kappa;
} else {
cosTheta = 1 + math::fastexp(-2*m_kappa) / m_kappa;
}
#endif #endif
Float sinTheta = math::safe_sqrt(1-cosTheta*cosTheta), Float sinTheta = math::safe_sqrt(1-cosTheta*cosTheta),