Add test/Kernel_23/test_approximate_dihedral_angle_3.cpp

This commit is contained in:
Laurent Rineau 2020-08-03 16:55:25 +02:00
parent b94c11ec4c
commit 09b52ce69f
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Kernel/global_functions_3.h>
#include <iostream>
#include <utility>
using K = CGAL::Simple_cartesian<double>;
using Point_3 = K::Point_3;
struct query {
Point_3 p;
double expected_angle;
};
int main() {
Point_3 a = {0, 0, 0};
Point_3 b = {0, 1, 0};
Point_3 c = {1, 0, 0};
const query queries[] = {
{ { 1, 0, 0}, 0.},
{ { 1, 0, 1}, 45.},
{ { 0, 0, 1}, 90.},
{ { -1, 0, 1}, 135.},
{ { -1, 0, 0}, 180.},
{ { -1, 0, -1}, -135.},
{ { 0, 0, -1}, -90.},
{ { 1, 0, -1}, -45.},
};
for(auto query: queries) {
const auto& expected = query.expected_angle;
const auto& p = query.p;
auto approx = CGAL::approximate_dihedral_angle(a, b, c, p);
std::cout << approx << " -- " << expected << '\n';
assert( std::abs(approx - expected) < 0.1 );
}
};