diff -u -r geometry.orig/strategies/strategy_transform.hpp geometry/strategies/strategy_transform.hpp --- geometry.orig/strategies/strategy_transform.hpp 2011-10-09 20:30:04.771874000 +0200 +++ geometry/strategies/strategy_transform.hpp 2011-11-23 10:56:47.143487500 +0100 @@ -251,6 +251,23 @@ return false; } + template + inline bool cartesian_to_spherical_equatorial3(T x, T y, T z, P& p) + { + assert_dimension(); + + // http://en.wikipedia.org/wiki/List_of_canonical_coordinate_transformations#From_Cartesian_coordinates + T const r = sqrt(x * x + y * y + z * z); + set<2>(p, r); + set_from_radian<0>(p, atan2(y, x)); + if (r > 0.0) + { + set_from_radian<1>(p, asin(z / r)); + return true; + } + return false; + } + } // namespace detail #endif // DOXYGEN_NO_DETAIL @@ -361,6 +378,16 @@ } }; +template +struct from_cartesian_3_to_spherical_equatorial_3 +{ + inline bool apply(P1 const& p1, P2& p2) const + { + assert_dimension(); + return detail::cartesian_to_spherical_equatorial3(get<0>(p1), get<1>(p1), get<2>(p1), p2); + } +}; + #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS namespace services @@ -454,6 +481,11 @@ { typedef from_cartesian_3_to_spherical_polar_3 type; }; +template +struct default_strategy +{ + typedef from_cartesian_3_to_spherical_equatorial_3 type; +}; } // namespace services