@@ -52,16 +52,15 @@ namespace geometry {
5252 return std::numeric_limits<Scalar>::quiet_NaN ();
5353 }
5454
55- // Our effective radius for the number of intersections
56- Scalar er = (h / 2 ) * (1 - std::pow (1 - 2 * r / h, 1 / k));
57-
58- // Valid below the horizon
55+ // Below the horizon with positive height
5956 if (h > 0 && phi_n < M_PI_2) {
57+ // Our effective radius for the number of intersections
58+ Scalar er = (h / 2 ) * (1 - std::pow (1 - 2 * r / h, 1 / k));
6059 return 2 * std::atan (er / (std::cos (phi_n) * (h - er)) + std::tan (phi_n)) - phi_n;
6160 }
62- // Valid above the horizon
61+ // Above the horizon with negative height
6362 else if (h < 0 && phi_n > M_PI_2) {
64- return 2 * std::atan (er / ( std::cos ( M_PI - phi_n) * (-h - er)) + std::tan ( M_PI - phi_n)) - M_PI - phi_n ;
63+ return M_PI - phi ( M_PI - phi_n, -h) ;
6564 }
6665 // Other situations are invalid so return NaN
6766 else {
@@ -84,11 +83,11 @@ namespace geometry {
8483 return std::numeric_limits<Scalar>::quiet_NaN ();
8584 }
8685
87- // Valid below the horizon
86+ // Below the horizon with positive height
8887 if (h > 0 && phi < M_PI_2) { return 2 * std::asin (r / ((h - r) * std::tan (phi))) / k; }
89- // Valid above the horizon
88+ // Above the horizon with negative height
9089 else if (h < 0 && phi > M_PI_2) {
91- return 2 * std::asin (r / (-(h - r) * std::tan ( M_PI - phi))) / k ;
90+ return theta ( M_PI - phi, -h) ;
9291 }
9392 // Other situations are invalid so return NaN
9493 else {
0 commit comments