]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/azimuth.cpp
4 // Copyright (c) 2021, Oracle and/or its affiliates.
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
8 // Licensed under the Boost Software License version 1.0.
9 // http://www.boost.org/users/license.html
12 #include <geometry_test_common.hpp>
14 #include <boost/geometry/geometries/geometries.hpp>
16 #include <boost/geometry/algorithms/azimuth.hpp>
19 template <typename P
, typename S
>
20 auto call_azimuth(P
const& p1
, P
const& p2
, S
const& s
)
22 return bg::azimuth(p1
, p2
, s
);
26 auto call_azimuth(P
const& p1
, P
const& p2
, bg::default_strategy
const&)
28 return bg::azimuth(p1
, p2
);
31 template <typename P
, typename S
= bg::default_strategy
>
32 void test_one(P
const& p1
, P
const& p2
, double expected
, S
const& s
= S())
34 double const result
= call_azimuth(p1
, p2
, s
) * bg::math::r2d
<double>();
35 BOOST_CHECK_CLOSE(result
, expected
, 0.0001);
41 test_one(P(0, 0), P(0, 0), 0);
42 test_one(P(0, 0), P(1, 1), 45);
43 test_one(P(0, 0), P(100, 1), 89.427061302316517);
44 test_one(P(0, 0), P(-1, 1), -45);
45 test_one(P(0, 0), P(-100, 1), -89.427061302316517);
51 test_one(P(0, 0), P(0, 0), 0);
52 test_one(P(0, 0), P(1, 1), 44.995636455344851);
53 test_one(P(0, 0), P(100, 1), 88.984576593576293);
54 test_one(P(0, 0), P(-1, 1), -44.995636455344851);
55 test_one(P(0, 0), P(-100, 1), -88.984576593576293);
61 test_one(P(0, 0), P(0, 0), 0);
62 test_one(P(0, 0), P(1, 1), 45.187718848049521);
63 test_one(P(0, 0), P(100, 1), 88.986933066023497);
64 test_one(P(0, 0), P(-1, 1), -45.187718848049521);
65 test_one(P(0, 0), P(-100, 1), -88.986933066023497);
71 bg::strategies::azimuth::geographic
<bg::strategy::vincenty
> s
;
73 test_one(P(0, 0), P(0, 0), 0, s
);
74 test_one(P(0, 0), P(1, 1), 45.188040229339755, s
);
75 test_one(P(0, 0), P(100, 1), 88.986914518230208, s
);
76 test_one(P(0, 0), P(-1, 1), -45.188040229339755, s
);
77 test_one(P(0, 0), P(-100, 1), -88.986914518230208, s
);
80 int test_main(int, char* [])
82 test_car
< bg::model::point
<double, 2, bg::cs::cartesian
> >();
83 test_sph
< bg::model::point
<double, 2, bg::cs::spherical_equatorial
<bg::degree
> > >();
84 test_geo
< bg::model::point
<double, 2, bg::cs::geographic
<bg::degree
> > >();
85 test_geo_v
< bg::model::point
<double, 2, bg::cs::geographic
<bg::degree
> > >();