diff -u -r geometry.orig/strategies/strategy_transform.hpp geometry/strategies/strategy_transform.hpp
|
old
|
new
|
|
| 251 | 251 | return false; |
| 252 | 252 | } |
| 253 | 253 | |
| | 254 | template <typename P, typename T> |
| | 255 | inline bool cartesian_to_spherical_equatorial3(T x, T y, T z, P& p) |
| | 256 | { |
| | 257 | assert_dimension<P, 3>(); |
| | 258 | |
| | 259 | // http://en.wikipedia.org/wiki/List_of_canonical_coordinate_transformations#From_Cartesian_coordinates |
| | 260 | T const r = sqrt(x * x + y * y + z * z); |
| | 261 | set<2>(p, r); |
| | 262 | set_from_radian<0>(p, atan2(y, x)); |
| | 263 | if (r > 0.0) |
| | 264 | { |
| | 265 | set_from_radian<1>(p, asin(z / r)); |
| | 266 | return true; |
| | 267 | } |
| | 268 | return false; |
| | 269 | } |
| | 270 | |
| 254 | 271 | } // namespace detail |
| 255 | 272 | #endif // DOXYGEN_NO_DETAIL |
| 256 | 273 | |
| … |
… |
|
| 361 | 378 | } |
| 362 | 379 | }; |
| 363 | 380 | |
| | 381 | template <typename P1, typename P2> |
| | 382 | struct from_cartesian_3_to_spherical_equatorial_3 |
| | 383 | { |
| | 384 | inline bool apply(P1 const& p1, P2& p2) const |
| | 385 | { |
| | 386 | assert_dimension<P1, 3>(); |
| | 387 | return detail::cartesian_to_spherical_equatorial3(get<0>(p1), get<1>(p1), get<2>(p1), p2); |
| | 388 | } |
| | 389 | }; |
| | 390 | |
| 364 | 391 | #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS |
| 365 | 392 | |
| 366 | 393 | namespace services |
| … |
… |
|
| 454 | 481 | { |
| 455 | 482 | typedef from_cartesian_3_to_spherical_polar_3<P1, P2> type; |
| 456 | 483 | }; |
| | 484 | template <typename CoordSys1, typename CoordSys2, typename P1, typename P2> |
| | 485 | struct default_strategy<cartesian_tag, spherical_equatorial_tag, CoordSys1, CoordSys2, 3, 3, P1, P2> |
| | 486 | { |
| | 487 | typedef from_cartesian_3_to_spherical_equatorial_3<P1, P2> type; |
| | 488 | }; |
| 457 | 489 | |
| 458 | 490 | |
| 459 | 491 | } // namespace services |