1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // This file is manually converted from PROJ4
4 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
10 // This file is converted from PROJ4, http://trac.osgeo.org/proj
11 // PROJ4 is originally written by Gerald Evenden (then of the USGS)
12 // PROJ4 is maintained by Frank Warmerdam
13 // PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
15 // Original copyright notice:
17 // Permission is hereby granted, free of charge, to any person obtaining a
18 // copy of this software and associated documentation files (the "Software"),
19 // to deal in the Software without restriction, including without limitation
20 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
21 // and/or sell copies of the Software, and to permit persons to whom the
22 // Software is furnished to do so, subject to the following conditions:
24 // The above copyright notice and this permission notice shall be included
25 // in all copies or substantial portions of the Software.
27 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
28 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
30 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
32 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
33 // DEALINGS IN THE SOFTWARE.
35 #ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP
36 #define BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP
41 #include <boost/geometry/util/math.hpp>
44 namespace boost { namespace geometry { namespace projections
53 inline T ONE_TOL() { return 1.00000000000001; }
54 //template <typename T>
55 //inline T TOL() { return 0.000000001; }
57 inline T ATOL() { return 1e-50; }
61 inline T aasin(T const& v)
65 if ((av = geometry::math::abs(v)) >= 1.0)
67 if (av > aasincos::ONE_TOL<T>())
69 BOOST_THROW_EXCEPTION( projection_exception(-19) );
71 return (v < 0.0 ? -geometry::math::half_pi<T>() : geometry::math::half_pi<T>());
78 inline T aacos(T const& v)
82 if ((av = geometry::math::abs(v)) >= 1.0)
84 if (av > aasincos::ONE_TOL<T>())
86 BOOST_THROW_EXCEPTION( projection_exception(-19) );
88 return (v < 0.0 ? geometry::math::pi<T>() : 0.0);
95 inline T asqrt(T const& v)
97 return ((v <= 0) ? 0 : sqrt(v));
100 template <typename T>
101 inline T aatan2(T const& n, T const& d)
103 return ((geometry::math::abs(n) < aasincos::ATOL<T>()
104 && geometry::math::abs(d) < aasincos::ATOL<T>()) ? 0.0 : atan2(n, d));
108 } // namespace detail
111 }}} // namespace boost::geometry::projections
114 #endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP