[formulas] Add asserts for validity of azimuth passed to thomas_direct and differential_quantities.

This commit is contained in:
Adam Wulkiewicz
2019-03-15 17:28:48 +01:00
parent aede53101b
commit e314795dbb
2 changed files with 7 additions and 0 deletions

View File

@@ -11,6 +11,7 @@
#ifndef BOOST_GEOMETRY_FORMULAS_INVERSE_DIFFERENTIAL_QUANTITIES_HPP
#define BOOST_GEOMETRY_FORMULAS_INVERSE_DIFFERENTIAL_QUANTITIES_HPP
#include <boost/geometry/core/assert.hpp>
#include <boost/geometry/util/condition.hpp>
#include <boost/geometry/util/math.hpp>
@@ -73,6 +74,9 @@ public:
CT const sig_12 = dlon / one_minus_f;
if (BOOST_GEOMETRY_CONDITION(EnableReducedLength))
{
CT const pi = math::pi<CT>();
BOOST_GEOMETRY_ASSERT(-pi <= azimuth && azimuth <= pi);
int azi_sign = math::sign(azimuth) >= 0 ? 1 : -1; // for antipodal
CT m12 = azi_sign * sin(sig_12) * b;
reduced_length = m12;

View File

@@ -15,6 +15,7 @@
#include <boost/math/constants/constants.hpp>
#include <boost/geometry/core/assert.hpp>
#include <boost/geometry/core/radius.hpp>
#include <boost/geometry/util/condition.hpp>
@@ -80,6 +81,8 @@ public:
CT const pi = math::pi<CT>();
CT const pi_half = pi / c2;
BOOST_GEOMETRY_ASSERT(-pi <= azimuth12 && azimuth12 <= pi);
// keep azimuth small - experiments show low accuracy
// if the azimuth is closer to (+-)180 deg.
CT azi12_alt = azimuth12;