ALL
0.9.4
A Loadbalacing Library
Toggle main menu visibility
Loading...
Searching...
No Matches
point_tetrahedron.cpp
Go to the documentation of this file.
1
/*
2
Copyright 2018-2020 Rene Halver, Forschungszentrum Juelich GmbH, Germany
3
Copyright 2018-2020 Godehard Sutmann, Forschungszentrum Juelich GmbH, Germany
4
5
Redistribution and use in source and binary forms, with or without modification,
6
are permitted provided that the following conditions are met:
7
8
1. Redistributions of source code must retain the above copyright notice, this
9
list of conditions and the following disclaimer.
10
11
2. Redistributions in binary form must reproduce the above copyright notice,
12
this list of conditions and the following disclaimer in the documentation and/or
13
other materials provided with the distribution.
14
15
3. Neither the name of the copyright holder nor the names of its contributors
16
may be used to endorse or promote products derived from this software without
17
specific prior written permission.
18
19
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31
#define BOOST_TEST_MAIN
32
33
#define BOOST_TEST_MODULE point_tetrahedron
34
#include "
ALL_Point.hpp
"
35
#include <boost/test/unit_test.hpp>
36
#include <vector>
37
38
BOOST_AUTO_TEST_SUITE(point_tetrahedron)
39
40
BOOST_AUTO_TEST_CASE
(tetrahedron_double) {
41
int
dimension = 3;
42
double
x = 2.5;
43
double
y = -5.7;
44
double
z = 8.3;
45
46
std::vector<double> A_data({0.0, 0.0, 0.0});
47
std::vector<double> B_data({1.0, 0.0, 0.0});
48
std::vector<double> C_data({0.0, 1.0, 0.0});
49
std::vector<double> D_data({0.0, 0.0, 1.0});
50
std::vector<double> P_data({0.25, 0.25, 0.25});
51
52
ALL::Point<double>
A(A_data);
53
ALL::Point<double>
B(B_data);
54
ALL::Point<double>
C(C_data);
55
ALL::Point<double>
D(D_data);
56
ALL::Point<double>
P(P_data);
57
58
BOOST_CHECK(P.
inTetrahedron
(A, B, C, D));
59
}
60
61
BOOST_AUTO_TEST_CASE
(tetrahedron_float) {
62
int
dimension = 3;
63
float
x = 2.5f;
64
float
y = -5.7f;
65
double
z = 8.3f;
66
67
std::vector<float> A_data({0.0f, 0.0f, 0.0f});
68
std::vector<float> B_data({1.0f, 0.0f, 0.0f});
69
std::vector<float> C_data({0.0f, 1.0f, 0.0f});
70
std::vector<float> D_data({0.0f, 0.0f, 1.0f});
71
std::vector<float> P_data({0.25f, 0.25f, 0.25f});
72
73
ALL::Point<float>
A(A_data);
74
ALL::Point<float>
B(B_data);
75
ALL::Point<float>
C(C_data);
76
ALL::Point<float>
D(D_data);
77
ALL::Point<float>
P(P_data);
78
79
BOOST_CHECK(P.
inTetrahedron
(A, B, C, D));
80
}
81
82
BOOST_AUTO_TEST_CASE
(tetrahedron_long_double) {
83
int
dimension = 3;
84
long
double
x = 2.5l;
85
long
double
y = -5.7l;
86
long
double
z = 8.3l;
87
88
std::vector<long double> A_data({0.0l, 0.0l, 0.0l});
89
std::vector<long double> B_data({1.0l, 0.0l, 0.0l});
90
std::vector<long double> C_data({0.0l, 1.0l, 0.0l});
91
std::vector<long double> D_data({0.0l, 0.0l, 1.0l});
92
std::vector<long double> P_data({0.25l, 0.25l, 0.25l});
93
94
ALL::Point<long double>
A(A_data);
95
ALL::Point<long double>
B(B_data);
96
ALL::Point<long double>
C(C_data);
97
ALL::Point<long double>
D(D_data);
98
ALL::Point<long double>
P(P_data);
99
100
BOOST_CHECK(P.
inTetrahedron
(A, B, C, D));
101
}
102
103
BOOST_AUTO_TEST_CASE
(tetrahedron_double_on_edge) {
104
int
dimension = 3;
105
double
x = 2.5;
106
double
y = -5.7;
107
double
z = 8.3;
108
109
std::vector<double> A_data({0.0, 0.0, 0.0});
110
std::vector<double> B_data({1.0, 0.0, 0.0});
111
std::vector<double> C_data({0.0, 1.0, 0.0});
112
std::vector<double> D_data({0.0, 0.0, 1.0});
113
std::vector<double> P_data({0.0, 0.5, 0.0});
114
115
ALL::Point<double>
A(A_data);
116
ALL::Point<double>
B(B_data);
117
ALL::Point<double>
C(C_data);
118
ALL::Point<double>
D(D_data);
119
ALL::Point<double>
P(P_data);
120
121
BOOST_CHECK(!P.
inTetrahedron
(A, B, C, D));
122
}
123
124
BOOST_AUTO_TEST_CASE
(tetrahedron_double_outside) {
125
int
dimension = 3;
126
double
x = 2.5;
127
double
y = -5.7;
128
double
z = 8.3;
129
130
std::vector<double> A_data({0.0, 0.0, 0.0});
131
std::vector<double> B_data({1.0, 0.0, 0.0});
132
std::vector<double> C_data({0.0, 1.0, 0.0});
133
std::vector<double> D_data({0.0, 0.0, 1.0});
134
std::vector<double> P_data({0.25, 0.25, 0.51});
135
136
ALL::Point<double>
A(A_data);
137
ALL::Point<double>
B(B_data);
138
ALL::Point<double>
C(C_data);
139
ALL::Point<double>
D(D_data);
140
ALL::Point<double>
P(P_data);
141
142
BOOST_CHECK(!P.
inTetrahedron
(A, B, C, D));
143
}
144
145
BOOST_AUTO_TEST_SUITE_END()
ALL_Point.hpp
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(empty)
Definition
all_class_creation.cpp:44
ALL::Point
Definition
ALL_Point.hpp:49
ALL::Point::inTetrahedron
bool inTetrahedron(const Point< T > &A, const Point< T > &B, const Point< T > &C, const Point< T > &D)
Definition
ALL_Point.hpp:354
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(tetrahedron_double)
Definition
point_tetrahedron.cpp:40
tests
unit
point_tetrahedron.cpp
Generated by
1.17.0