|
||||
File indexing completed on 2025-01-18 09:35:37
0001 // Boost.Geometry (aka GGL, Generic Geometry Library) 0002 // This file is manually converted from PROJ4 0003 0004 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands. 0005 0006 // This file was modified by Oracle on 2018. 0007 // Modifications copyright (c) 2018, Oracle and/or its affiliates. 0008 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle 0009 0010 // Use, modification and distribution is subject to the Boost Software License, 0011 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 0012 // http://www.boost.org/LICENSE_1_0.txt) 0013 0014 // This file is converted from PROJ4, http://trac.osgeo.org/proj 0015 // PROJ4 is originally written by Gerald Evenden (then of the USGS) 0016 // PROJ4 is maintained by Frank Warmerdam 0017 // PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam) 0018 0019 // Original copyright notice: 0020 0021 // Permission is hereby granted, free of charge, to any person obtaining a 0022 // copy of this software and associated documentation files (the "Software"), 0023 // to deal in the Software without restriction, including without limitation 0024 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 0025 // and/or sell copies of the Software, and to permit persons to whom the 0026 // Software is furnished to do so, subject to the following conditions: 0027 0028 // The above copyright notice and this permission notice shall be included 0029 // in all copies or substantial portions of the Software. 0030 0031 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 0032 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0033 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 0034 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 0035 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 0036 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 0037 // DEALINGS IN THE SOFTWARE. 0038 0039 #ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP 0040 #define BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP 0041 0042 0043 #include <cmath> 0044 0045 #include <boost/geometry/srs/projections/exception.hpp> 0046 #include <boost/geometry/srs/projections/impl/pj_strerrno.hpp> 0047 #include <boost/geometry/util/math.hpp> 0048 0049 0050 namespace boost { namespace geometry { namespace projections 0051 { 0052 0053 namespace detail 0054 { 0055 0056 namespace aasincos 0057 { 0058 template <typename T> 0059 inline T ONE_TOL() { return 1.00000000000001; } 0060 //template <typename T> 0061 //inline T TOL() { return 0.000000001; } 0062 template <typename T> 0063 inline T ATOL() { return 1e-50; } 0064 } 0065 0066 template <typename T> 0067 inline T aasin(T const& v) 0068 { 0069 T av = 0; 0070 0071 if ((av = geometry::math::abs(v)) >= 1.0) 0072 { 0073 if (av > aasincos::ONE_TOL<T>()) 0074 { 0075 BOOST_THROW_EXCEPTION( projection_exception(error_acos_asin_arg_too_large) ); 0076 } 0077 return (v < 0.0 ? -geometry::math::half_pi<T>() : geometry::math::half_pi<T>()); 0078 } 0079 0080 return asin(v); 0081 } 0082 0083 template <typename T> 0084 inline T aacos(T const& v) 0085 { 0086 T av = 0; 0087 0088 if ((av = geometry::math::abs(v)) >= 1.0) 0089 { 0090 if (av > aasincos::ONE_TOL<T>()) 0091 { 0092 BOOST_THROW_EXCEPTION( projection_exception(error_acos_asin_arg_too_large) ); 0093 } 0094 return (v < 0.0 ? geometry::math::pi<T>() : 0.0); 0095 } 0096 0097 return acos(v); 0098 } 0099 0100 template <typename T> 0101 inline T asqrt(T const& v) 0102 { 0103 return ((v <= 0) ? 0 : sqrt(v)); 0104 } 0105 0106 template <typename T> 0107 inline T aatan2(T const& n, T const& d) 0108 { 0109 return ((geometry::math::abs(n) < aasincos::ATOL<T>() 0110 && geometry::math::abs(d) < aasincos::ATOL<T>()) ? 0.0 : atan2(n, d)); 0111 } 0112 0113 0114 } // namespace detail 0115 0116 0117 }}} // namespace boost::geometry::projections 0118 0119 0120 #endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |