Use CGAL::approximate_angle()

This commit is contained in:
Andreas Fabri 2023-01-05 13:41:38 +00:00
parent b8df872370
commit 2c06334ee7
4 changed files with 3 additions and 22 deletions

View File

@ -115,26 +115,6 @@ inline const Vector_d normalize(const Vector_d& v) {
return v / static_cast<FT>(CGAL::sqrt(CGAL::to_double(dot_product)));
}
// Compute angle between two 3D vectors.
template<typename Vector_3>
typename Kernel_traits<Vector_3>::Kernel::FT
angle_3d(const Vector_3& v1, const Vector_3& v2) {
using Traits = typename Kernel_traits<Vector_3>::Kernel;
using FT = typename Traits::FT;
const double a = CGAL::to_double(v1 * v2) / (
CGAL::sqrt(CGAL::to_double(v1.squared_length())) *
CGAL::sqrt(CGAL::to_double(v2.squared_length())) );
if (a < -1.0) {
return static_cast<FT>(std::acos(-1.0) / CGAL_PI * 180.0);
} else if (a > 1.0) {
return static_cast<FT>(std::acos(+1.0) / CGAL_PI * 180.0);
} else {
return static_cast<FT>(std::acos( a) / CGAL_PI * 180.0);
}
}
// Intersections. Used only in the 2D version.
// For the 3D version, see conversions.h!

View File

@ -16,6 +16,7 @@
// #include <CGAL/license/Kinetic_shape_reconstruction.h>
// CGAL includes.
#include <CGAL/Timer.h>
#include <CGAL/optimal_bounding_box.h>
#include <CGAL/Boolean_set_operations_2.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

View File

@ -742,7 +742,7 @@ private:
CGAL_assertion(idx < m_input_range.size());
const auto& normal = get(m_normal_map_3, idx);
FT angle = KSR::angle_3d(normal, ref);
FT angle = approximate_angle(normal, ref);
if (angle > FT(90)) angle = FT(180) - angle;
angle = FT(90) - angle;
if (angle <= max_accepted_angle) wall_points.push_back(idx);

View File

@ -928,7 +928,7 @@ bool operator==(const Support_plane<Kernel>& a, const Support_plane<Kernel>& b)
// }
const FT vtol = FT(5); // degrees // TODO: We should put it as a parameter.
FT aval = KSR::angle_3d(va, vb);
FT aval = approximate_angle(va, vb);
CGAL_assertion(aval >= FT(0) && aval <= FT(180));
if (aval >= FT(90)) aval = FT(180) - aval;