GCC Code Coverage Report


Directory: Bembel/src/
File: Bembel/src/util/GeometryHelper.hpp
Date: 2024-09-30 07:01:38
Exec Total Coverage
Lines: 12 12 100.0%
Functions: 1 1 100.0%
Branches: 14 24 58.3%

Line Branch Exec Source
1 // This file is part of Bembel, the higher order C++ boundary element library.
2 //
3 // Copyright (C) 2024 see <http://www.bembel.eu>
4 //
5 // It was written as part of a cooperation of J. Doelz, H. Harbrecht, S. Kurz,
6 // M. Multerer, S. Schoeps, and F. Wolf at Technische Universitaet Darmstadt,
7 // Universitaet Basel, and Universita della Svizzera italiana, Lugano. This
8 // source code is subject to the GNU General Public License version 3 and
9 // provided WITHOUT ANY WARRANTY, see <http://www.bembel.eu> for further
10 // information.
11
12 #ifndef BEMBEL_SRC_UTIL_GEOMETRYHELPER_HPP_
13 #define BEMBEL_SRC_UTIL_GEOMETRYHELPER_HPP_
14
15 namespace Bembel {
16 namespace util {
17
18 /**
19 * \brief computes a ball enclosing of two given enclosing balls.
20 *
21 * The computed enclosing ball contains for sure the two given balls with
22 * mit_point1 and radius1 and 2, respectively.
23 *
24 * \param *midpoint: Pointer to Eigen::Vector3d which is the new mid point of
25 * the enclosing ball
26 * \param *radius: Pointer where the radius of new enclosing ball is saved.
27 * \param midpoint1: Eigen::Vector3d midpoint of the first ball
28 * \param radius1: double radius of the first ball
29 * \param midpoint2: Eigen::Vector3d midpoint of the second ball
30 * \param radius2: double radius of the second ball
31 */
32 73407 void computeEnclosingBall(Eigen::Vector3d *midpoint, double *radius,
33 const Eigen::Vector3d &midpoint1, double radius1,
34 const Eigen::Vector3d &midpoint2, double radius2) {
35 // compute distance vector of the two spheres
36
1/2
✓ Branch 1 taken 73407 times.
✗ Branch 2 not taken.
73407 auto z = midpoint1 - midpoint2;
37
2/4
✓ Branch 1 taken 73407 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 73407 times.
✗ Branch 5 not taken.
73407 auto norm = (midpoint1 - midpoint2).norm();
38 // B(d2,radius2) subset B(d1,radius1)
39
2/2
✓ Branch 0 taken 24021 times.
✓ Branch 1 taken 49386 times.
73407 if (norm + radius2 <= radius1) {
40
1/2
✓ Branch 1 taken 24021 times.
✗ Branch 2 not taken.
24021 *midpoint = midpoint1;
41 24021 *radius = radius1;
42 // B(d1,radius1) subset B(d2,radius2)
43
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 49338 times.
49386 } else if (norm + radius1 <= radius2) {
44
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
48 *midpoint = midpoint2;
45 48 *radius = radius2;
46 // the union is not a ball
47 } else {
48
5/10
✓ Branch 1 taken 49338 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 49338 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 49338 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 49338 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 49338 times.
✗ Branch 14 not taken.
49338 *midpoint = 0.5 * (midpoint1 + midpoint2 + (radius1 - radius2) / norm * z);
49 49338 *radius = 0.5 * (radius1 + radius2 + norm);
50 }
51 146814 return;
52 }
53 } // namespace util
54 } // namespace Bembel
55 #endif // BEMBEL_SRC_UTIL_GEOMETRYHELPER_HPP_
56