From 65d630536b521d41af913a9f0ebb26b9e4fc0197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 15 Jun 2021 14:36:26 +0200 Subject: [PATCH] factorize --- .../internal/Bbox_3_Triangle_3_do_intersect.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Triangle_3_do_intersect.h b/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Triangle_3_do_intersect.h index 89e3a497ca7..5245c40ff44 100644 --- a/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Triangle_3_do_intersect.h +++ b/Intersections_3/include/CGAL/Intersections_3/internal/Bbox_3_Triangle_3_do_intersect.h @@ -140,6 +140,16 @@ namespace internal { } } + template + inline + Sign + do_axis_intersect_aux_impl(const typename K::FT& alpha, + const typename K::FT& beta, + const typename K::FT& c_alpha, + const typename K::FT& c_beta) + { + return - c_alpha * alpha + c_beta * beta; + } template inline @@ -148,7 +158,7 @@ namespace internal { const typename K::FT& beta, const typename K::Vector_3* sides) { - return -sides[SIDE].z()*alpha + sides[SIDE].y()*beta; + return do_axis_intersect_aux_impl(alpha, beta, sides[SIDE].z(), sides[SIDE].y()); } template @@ -158,7 +168,7 @@ namespace internal { const typename K::FT& beta, const typename K::Vector_3* sides) { - return sides[SIDE].z()*alpha - sides[SIDE].x()*beta; + return do_axis_intersect_aux_impl(beta, alpha, sides[SIDE].x(), sides[SIDE].z()); } template @@ -168,7 +178,7 @@ namespace internal { const typename K::FT& beta, const typename K::Vector_3* sides) { - return -sides[SIDE].y()*alpha + sides[SIDE].x()*beta; + return do_axis_intersect_aux_impl(alpha, beta, sides[SIDE].y(), sides[SIDE].x()); } //given a vector checks whether it is collinear to a base vector