Skip to content

Commit

Permalink
Stop using non-standard M_PI
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisThrasher committed Dec 12, 2023
1 parent 4dc8804 commit f9910d7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ auto rng(std::seed_seq seed_sequence) -> std::mt19937& {
}

auto random_unit_quaternion() -> Eigen::Quaterniond {
static constexpr auto pi = 3.1415926535897932385;

// From "Uniform Random Rotations", Ken Shoemake, Graphics Gems III, pg. 124-132
auto const x0 = uniform_real(0., 1.);
auto const r1 = std::sqrt(1 - x0);
auto const r2 = std::sqrt(x0);
auto const t1 = uniform_real(0., 2 * M_PI);
auto const t2 = uniform_real(0., 2 * M_PI);
auto const t1 = uniform_real(0., 2 * pi);
auto const t2 = uniform_real(0., 2 * pi);
auto const x = r1 * std::sin(t1);
auto const y = r1 * std::cos(t1);
auto const z = r2 * std::sin(t2);
Expand Down

0 comments on commit f9910d7

Please sign in to comment.