From b896888ec30e2d41084aed48368d207fbc6712e2 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sat, 9 Jul 2011 13:20:55 +0000 Subject: [PATCH] Added strategy to convert spherical equatorial [SVN r72981] --- .../strategies/strategy_transform.hpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/boost/geometry/strategies/strategy_transform.hpp b/include/boost/geometry/strategies/strategy_transform.hpp index 34e19fc77..0410833ca 100644 --- a/include/boost/geometry/strategies/strategy_transform.hpp +++ b/include/boost/geometry/strategies/strategy_transform.hpp @@ -222,6 +222,17 @@ namespace detail set_from_radian<1>(p, acos(z)); return true; } + + template + inline bool cartesian_to_spherical_equatorial2(T x, T y, T z, P& p) + { + assert_dimension(); + + set_from_radian<0>(p, atan2(y, x)); + set_from_radian<1>(p, asin(z)); + return true; + } + template inline bool cartesian_to_spherical3(T x, T y, T z, P& p) @@ -323,6 +334,16 @@ struct from_cartesian_3_to_spherical_polar_2 } }; +template +struct from_cartesian_3_to_spherical_equatorial_2 +{ + inline bool apply(P1 const& p1, P2& p2) const + { + assert_dimension(); + return detail::cartesian_to_spherical_equatorial2(get<0>(p1), get<1>(p1), get<2>(p1), p2); + } +}; + /*! \brief Transformation strategy for 3D cartesian (x,y,z) to 3D spherical (phi,theta,r) @@ -421,6 +442,12 @@ struct default_strategy type; }; +template +struct default_strategy +{ + typedef from_cartesian_3_to_spherical_equatorial_2 type; +}; + /// Specialization to transform from XYZ to sphere(phi,theta,r) template struct default_strategy