]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/srs/projections/impl/aasincos.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / geometry / srs / projections / impl / aasincos.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // This file is manually converted from PROJ4
3
4 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
5
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)
9
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)
14
15 // Original copyright notice:
16
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:
23
24 // The above copyright notice and this permission notice shall be included
25 // in all copies or substantial portions of the Software.
26
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.
34
35 #ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP
36 #define BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP
37
38
39 #include <cmath>
40
41 #include <boost/geometry/util/math.hpp>
42
43
44 namespace boost { namespace geometry { namespace projections
45 {
46
47 namespace detail
48 {
49
50 namespace aasincos
51 {
52 template <typename T>
53 inline T ONE_TOL() { return 1.00000000000001; }
54 //template <typename T>
55 //inline T TOL() { return 0.000000001; }
56 template <typename T>
57 inline T ATOL() { return 1e-50; }
58 }
59
60 template <typename T>
61 inline T aasin(T const& v)
62 {
63 T av = 0;
64
65 if ((av = geometry::math::abs(v)) >= 1.0)
66 {
67 if (av > aasincos::ONE_TOL<T>())
68 {
69 BOOST_THROW_EXCEPTION( projection_exception(-19) );
70 }
71 return (v < 0.0 ? -geometry::math::half_pi<T>() : geometry::math::half_pi<T>());
72 }
73
74 return asin(v);
75 }
76
77 template <typename T>
78 inline T aacos(T const& v)
79 {
80 T av = 0;
81
82 if ((av = geometry::math::abs(v)) >= 1.0)
83 {
84 if (av > aasincos::ONE_TOL<T>())
85 {
86 BOOST_THROW_EXCEPTION( projection_exception(-19) );
87 }
88 return (v < 0.0 ? geometry::math::pi<T>() : 0.0);
89 }
90
91 return acos(v);
92 }
93
94 template <typename T>
95 inline T asqrt(T const& v)
96 {
97 return ((v <= 0) ? 0 : sqrt(v));
98 }
99
100 template <typename T>
101 inline T aatan2(T const& n, T const& d)
102 {
103 return ((geometry::math::abs(n) < aasincos::ATOL<T>()
104 && geometry::math::abs(d) < aasincos::ATOL<T>()) ? 0.0 : atan2(n, d));
105 }
106
107
108 } // namespace detail
109
110
111 }}} // namespace boost::geometry::projections
112
113
114 #endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP