Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72981 - trunk/boost/geometry/strategies
From: barend.gehrels_at_[hidden]
Date: 2011-07-09 09:20:55


Author: barendgehrels
Date: 2011-07-09 09:20:55 EDT (Sat, 09 Jul 2011)
New Revision: 72981
URL: http://svn.boost.org/trac/boost/changeset/72981

Log:
Added strategy to convert spherical equatorial
Text files modified:
   trunk/boost/geometry/strategies/strategy_transform.hpp | 27 +++++++++++++++++++++++++++
   1 files changed, 27 insertions(+), 0 deletions(-)

Modified: trunk/boost/geometry/strategies/strategy_transform.hpp
==============================================================================
--- trunk/boost/geometry/strategies/strategy_transform.hpp (original)
+++ trunk/boost/geometry/strategies/strategy_transform.hpp 2011-07-09 09:20:55 EDT (Sat, 09 Jul 2011)
@@ -222,6 +222,17 @@
         set_from_radian<1>(p, acos(z));
         return true;
     }
+
+ template <typename P, typename T>
+ inline bool cartesian_to_spherical_equatorial2(T x, T y, T z, P& p)
+ {
+ assert_dimension<P, 2>();
+
+ set_from_radian<0>(p, atan2(y, x));
+ set_from_radian<1>(p, asin(z));
+ return true;
+ }
+
 
     template <typename P, typename T>
     inline bool cartesian_to_spherical3(T x, T y, T z, P& p)
@@ -323,6 +334,16 @@
     }
 };
 
+template <typename P1, typename P2>
+struct from_cartesian_3_to_spherical_equatorial_2
+{
+ inline bool apply(P1 const& p1, P2& p2) const
+ {
+ assert_dimension<P1, 3>();
+ 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 @@
     typedef from_cartesian_3_to_spherical_polar_2<P1, P2> type;
 };
 
+template <typename CoordSys1, typename CoordSys2, typename P1, typename P2>
+struct default_strategy<cartesian_tag, spherical_equatorial_tag, CoordSys1, CoordSys2, 3, 2, P1, P2>
+{
+ typedef from_cartesian_3_to_spherical_equatorial_2<P1, P2> type;
+};
+
 /// Specialization to transform from XYZ to sphere(phi,theta,r)
 template <typename CoordSys1, typename CoordSys2, typename P1, typename P2>
 struct default_strategy<cartesian_tag, spherical_polar_tag, CoordSys1, CoordSys2, 3, 3, P1, P2>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk