123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #ifndef BOOST_GEOMETRY_PROJECTIONS_PHI2_HPP
- #define BOOST_GEOMETRY_PROJECTIONS_PHI2_HPP
- #include <boost/geometry/srs/projections/exception.hpp>
- #include <boost/geometry/srs/projections/impl/pj_strerrno.hpp>
- #include <boost/geometry/util/math.hpp>
- namespace boost { namespace geometry { namespace projections {
- namespace detail {
- template <typename T>
- inline T pj_phi2(T const& ts, T const& e)
- {
- static const T TOL = 1.0e-10;
- static const int N_ITER = 15;
- T eccnth, Phi, con, dphi;
- int i;
- eccnth = .5 * e;
- Phi = geometry::math::half_pi<T>() - 2. * atan (ts);
- i = N_ITER;
- do {
- con = e * sin (Phi);
- dphi = geometry::math::half_pi<T>() - 2. * atan (ts * math::pow((T(1) - con) /
- (T(1) + con), eccnth)) - Phi;
- Phi += dphi;
- } while ( geometry::math::abs(dphi) > TOL && --i);
- if (i <= 0)
- BOOST_THROW_EXCEPTION( projection_exception(error_non_con_inv_phi2) );
- return Phi;
- }
- }
- }}}
- #endif
|