123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- #ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP
- #define BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP
- #include <cmath>
- #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
- {
- namespace aasincos
- {
- template <typename T>
- inline T ONE_TOL() { return 1.00000000000001; }
-
-
- template <typename T>
- inline T ATOL() { return 1e-50; }
- }
- template <typename T>
- inline T aasin(T const& v)
- {
- T av = 0;
- if ((av = geometry::math::abs(v)) >= 1.0)
- {
- if (av > aasincos::ONE_TOL<T>())
- {
- BOOST_THROW_EXCEPTION( projection_exception(error_acos_asin_arg_too_large) );
- }
- return (v < 0.0 ? -geometry::math::half_pi<T>() : geometry::math::half_pi<T>());
- }
- return asin(v);
- }
- template <typename T>
- inline T aacos(T const& v)
- {
- T av = 0;
- if ((av = geometry::math::abs(v)) >= 1.0)
- {
- if (av > aasincos::ONE_TOL<T>())
- {
- BOOST_THROW_EXCEPTION( projection_exception(error_acos_asin_arg_too_large) );
- }
- return (v < 0.0 ? geometry::math::pi<T>() : 0.0);
- }
- return acos(v);
- }
- template <typename T>
- inline T asqrt(T const& v)
- {
- return ((v <= 0) ? 0 : sqrt(v));
- }
- template <typename T>
- inline T aatan2(T const& n, T const& d)
- {
- return ((geometry::math::abs(n) < aasincos::ATOL<T>()
- && geometry::math::abs(d) < aasincos::ATOL<T>()) ? 0.0 : atan2(n, d));
- }
- }
- }}}
- #endif
|