Boost.Geometry Projections now use Boost.Math constants

[SVN r77184]
This commit is contained in:
Barend Gehrels
2012-03-03 19:53:05 +00:00
parent b9b6be97f9
commit 4156da7bbf
2 changed files with 17 additions and 19 deletions

View File

@@ -35,13 +35,9 @@
#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_ADJLON_HPP
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_ADJLON_HPP
#include <cmath>
#include <boost/math/constants/constants.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
namespace boost { namespace geometry { namespace projection
{
@@ -49,20 +45,21 @@ namespace detail
{
/* reduce argument to range +/- PI */
inline double adjlon (double lon)
template <typename T>
inline T adjlon (T lon)
{
const double SPI = 3.14159265359;
const double TWOPI = 6.2831853071795864769;
const double ONEPI = 3.14159265358979323846;
if (geometry::math::abs(lon) <= SPI)
if (geometry::math::abs(lon) <= boost::math::constants::pi<T>())
{
return lon;
}
lon += ONEPI; /* adjust to 0..2pi rad */
lon -= TWOPI * std::floor(lon / TWOPI); /* remove integral # of 'revolutions'*/
lon -= ONEPI; /* adjust back to -pi..pi rad */
/* adjust to 0..2pi rad */
lon += boost::math::constants::pi<T>();
/* remove integral # of 'revolutions'*/
lon -= boost::math::constants::two_pi<T>() *
std::floor(lon / boost::math::constants::two_pi<T>());
/* adjust back to -pi..pi rad */
lon -= boost::math::constants::pi<T>();
return lon;
}

View File

@@ -40,6 +40,7 @@
#include <vector>
#include <boost/concept_check.hpp>
#include <boost/math/constants/constants.hpp>
namespace boost { namespace geometry { namespace projection
{
@@ -49,13 +50,13 @@ namespace detail
{
/* some useful constants */
static const double HALFPI = 1.5707963267948966;
static const double FORTPI = 0.78539816339744833;
static const double PI = 3.14159265358979323846;
static const double TWOPI = 6.2831853071795864769;
static const double HALFPI = boost::math::constants::half_pi<double>();
static const double FORTPI = boost::math::constants::pi<double>() / 4.0;
static const double PI = boost::math::constants::pi<double>();
static const double TWOPI = boost::math::constants::two_pi<double>();
static const double RAD_TO_DEG = 57.29577951308232;
static const double DEG_TO_RAD = .0174532925199432958;
static const double RAD_TO_DEG = boost::math::constants::radian<double>();
static const double DEG_TO_RAD = boost::math::constants::degree<double>();
static const int PJD_UNKNOWN =0;
static const int PJD_3PARAM = 1;