From 9073aa5f72998ea40e137ccaa3a236f789866662 Mon Sep 17 00:00:00 2001 From: Christopher Fichtlscherer <29277544+cfichtlscherer@users.noreply.github.com> Date: Tue, 10 May 2022 09:17:50 +0200 Subject: [PATCH] Update src/distribution_spatial.cpp Co-authored-by: Paul Romano --- src/distribution_spatial.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/distribution_spatial.cpp b/src/distribution_spatial.cpp index 2542842c32..a06f84d808 100644 --- a/src/distribution_spatial.cpp +++ b/src/distribution_spatial.cpp @@ -174,8 +174,8 @@ Position SphericalIndependent::sample(uint64_t* seed) const double cos_theta = cos_theta_->sample(seed); double phi = phi_->sample(seed); // sin(theta) by sin**2 + cos**2 = 1 - double x = r * std::pow(1 - std::pow(cos_theta, 2.0), 0.5) * cos(phi) + origin_.x; - double y = r * std::pow(1 - std::pow(cos_theta, 2.0), 0.5) * sin(phi) + origin_.y; + double x = r * std::sqrt(1 - cos_theta * cos_theta) * cos(phi) + origin_.x; + double y = r * std::sqrt(1 - cos_theta * cos_theta) * sin(phi) + origin_.y; double z = r * cos_theta + origin_.z; return {x, y, z}; }