]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/arithmetic/cross_product.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
5 // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
7 // This file was modified by Oracle on 2020.
8 // Modifications copyright (c) 2020, Oracle and/or its affiliates.
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
16 #include <geometry_test_common.hpp>
18 #include <boost/core/ignore_unused.hpp>
20 #include <boost/geometry/arithmetic/cross_product.hpp>
22 #include <boost/geometry/algorithms/assign.hpp>
24 #include <boost/geometry/geometries/point.hpp>
25 #include <boost/geometry/geometries/adapted/c_array.hpp>
26 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
27 #include <test_common/test_point.hpp>
34 bg::assign_values(p1
, 20, 30);
36 bg::assign_values(p2
, 45, 70);
37 P c
= bg::cross_product(p1
, p2
);
39 typedef typename
bg::coordinate_type
<P
>::type scalar_type
;
40 BOOST_CHECK_EQUAL(bg::get
<0>(c
), scalar_type(50));
47 bg::assign_values(p1
, 20, 30, 10);
49 bg::assign_values(p2
, 45, 70, 20);
50 P c
= bg::cross_product(p1
, p2
);
52 typedef typename
bg::coordinate_type
<P
>::type scalar_type
;
53 BOOST_CHECK_EQUAL(bg::get
<0>(c
), scalar_type(-100));
54 BOOST_CHECK_EQUAL(bg::get
<1>(c
), scalar_type(50));
55 BOOST_CHECK_EQUAL(bg::get
<2>(c
), scalar_type(50));
61 constexpr P p1
= P(20, 30, 10);
62 constexpr P p2
= P(45, 70, 20);
63 constexpr P c
= bg::cross_product(p1
, p2
);
64 constexpr auto c0
= bg::get
<0>(c
);
65 constexpr auto c1
= bg::get
<1>(c
);
66 constexpr auto c2
= bg::get
<2>(c
);
67 BOOST_CHECK_EQUAL(c0
, -100);
68 BOOST_CHECK_EQUAL(c1
, 50);
69 BOOST_CHECK_EQUAL(c2
, 50);
72 #ifdef TEST_FAIL_CROSS_PRODUCT
77 bg::assign_values(p1
, 20, 30, 10);
80 bg::assign_values(p2
, 45, 70, 20);
82 P c
= bg::cross_product(p1
, p2
);
83 boost::ignore_unused(c
);
87 int test_main(int, char* [])
89 test_2d
<bg::model::point
<int, 2, bg::cs::cartesian
> >();
90 test_2d
<bg::model::point
<float, 2, bg::cs::cartesian
> >();
91 test_2d
<bg::model::point
<double, 2, bg::cs::cartesian
> >();
93 test_3d
<bg::model::point
<int, 3, bg::cs::cartesian
> >();
94 test_3d
<bg::model::point
<float, 3, bg::cs::cartesian
> >();
95 test_3d
<bg::model::point
<double, 3, bg::cs::cartesian
> >();
97 #ifdef TEST_FAIL_CROSS_PRODUCT
98 test_4d
<bg::model::point
<int, 4, bg::cs::cartesian
> >();
99 test_4d
<bg::model::point
<float, 4, bg::cs::cartesian
> >();
100 test_4d
<bg::model::point
<double, 4, bg::cs::cartesian
> >();
103 test_constexpr
<bg::model::point
<double, 3, bg::cs::cartesian
> >();