// Boost.Geometry // Copyright (c) 2016, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GEOMETRY_FORMULAS_SPHERICAL_HPP #define BOOST_GEOMETRY_FORMULAS_SPHERICAL_HPP #include #include #include #include //#include #include #include #include #include #include namespace boost { namespace geometry { namespace formula { template static inline Point3d sph_to_cart3d(PointSph const& point_sph) { typedef typename coordinate_type::type calc_t; Point3d res; calc_t lon = get_as_radian<0>(point_sph); calc_t lat = get_as_radian<1>(point_sph); calc_t const cos_lat = cos(lat); set<0>(res, cos_lat * cos(lon)); set<1>(res, cos_lat * sin(lon)); set<2>(res, sin(lat)); return res; } template static inline PointSph cart3d_to_sph(Point3d const& point_3d) { typedef typename coordinate_type::type coord_t; typedef typename coordinate_type::type calc_t; PointSph res; calc_t const x = get<0>(point_3d); calc_t const y = get<1>(point_3d); calc_t const z = get<2>(point_3d); set_from_radian<0>(res, atan2(y, x)); set_from_radian<1>(res, asin(z)); coord_t lon = get<0>(res); coord_t lat = get<1>(res); math::normalize_spheroidal_coordinates < typename coordinate_system::type::units, coord_t >(lon, lat); set<0>(res, lon); set<1>(res, lat); return res; } // -1 right // 1 left // 0 on template static inline int sph_side_value(Point3d1 const& norm, Point3d2 const& pt) { typedef typename select_coordinate_type::type calc_t; calc_t c0 = 0; calc_t d = dot_product(norm, pt); return math::equals(d, c0) ? 0 : d > c0 ? 1 : -1; // d < 0 } } // namespace formula }} // namespace boost::geometry #endif // BOOST_GEOMETRY_FORMULAS_SPHERICAL_HPP