Change convention on rotate_angle originally suggested by @smharper

This commit is contained in:
Paul Romano 2021-03-24 07:55:33 -05:00
parent c64e64dac2
commit de2cbe0c1e
2 changed files with 3 additions and 14 deletions

View file

@ -62,11 +62,6 @@ Direction PolarAzimuthal::sample(uint64_t* seed) const
// Sample azimuthal angle
double phi = phi_->sample(seed);
// If the reference direction is along the z-axis, rotate the aziumthal angle
// to match spherical coordinate conventions.
// TODO: apply this change directly to rotate_angle
if (u_ref_.x == 0 && u_ref_.y == 0) phi += 0.5*PI;
return rotate_angle(u_ref_, mu, &phi, seed);
}

View file

@ -662,15 +662,9 @@ Direction rotate_angle(Direction u, double mu, const double* phi, uint64_t* seed
mu*u.z - a*b*cosphi};
} else {
b = std::sqrt(1. - u.y*u.y);
return {mu*u.x + a*(u.x*u.y*cosphi + u.z*sinphi) / b,
mu*u.y - a*b*cosphi,
mu*u.z + a*(u.y*u.z*cosphi - u.x*sinphi) / b};
// TODO: use the following code to make PolarAzimuthal distributions match
// spherical coordinate conventions. Remove the related fixup code in
// PolarAzimuthal::sample.
//return {mu*u.x + a*(-u.x*u.y*sinphi + u.z*cosphi) / b,
// mu*u.y + a*b*sinphi,
// mu*u.z - a*(u.y*u.z*sinphi + u.x*cosphi) / b};
return {mu*u.x + a*(-u.x*u.y*sinphi + u.z*cosphi) / b,
mu*u.y + a*b*sinphi,
mu*u.z - a*(u.y*u.z*sinphi + u.x*cosphi) / b};
}
}