From 3c7eb2c6b96527c15d069582a738fcd1ec5acfd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 7 Jan 2020 15:31:07 +0100 Subject: [PATCH] Use CGAL_PI instead of hardcoding it --- .../DH_speed_test_100_vertices.cpp | 4 ++-- .../MV_speed_test_100_vertices.cpp | 4 ++-- .../WP_speed_test_100_vertices.cpp | 4 ++-- Generator/include/CGAL/point_generators_d.h | 8 ++++---- .../scene.h | 8 +++++--- .../include/CGAL/bilateral_smooth_point_set.h | 3 ++- Ridges_3/include/CGAL/Umbilics.h | 19 ++++++++++--------- .../include/CGAL/Snap_rounding_kd_2.h | 3 ++- .../Straight_skeleton_builder_2_impl.h | 7 ++++--- 9 files changed, 33 insertions(+), 27 deletions(-) diff --git a/Barycentric_coordinates_2/benchmark/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_speed_test_100_vertices.cpp b/Barycentric_coordinates_2/benchmark/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_speed_test_100_vertices.cpp index 561a45ccecd..0b37ce54e32 100644 --- a/Barycentric_coordinates_2/benchmark/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_speed_test_100_vertices.cpp +++ b/Barycentric_coordinates_2/benchmark/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_speed_test_100_vertices.cpp @@ -2,6 +2,7 @@ // We test speed of discrete harmonic coordinates on a set of automatically generated // points inside a regular polygon with 100 vertices. We use inexact kernel. +#include #include #include #include @@ -28,12 +29,11 @@ void generate_regular_polygon(const int number_of_vertices, const double polygon { const int n = number_of_vertices; const double r = polygon_radius; - const double number_pi = 3.14159; vertices.resize(n); for(int i = 0; i < n; ++i) - vertices[i] = Point(Scalar(r*sin((number_pi / n) + ((i * 2.0 * number_pi) / n))), Scalar(-r*cos((number_pi / n) + ((i * 2.0 * number_pi) / n)))); + vertices[i] = Point(Scalar(r*sin((CGAL_PI / n) + ((i * 2.0 * CGAL_PI) / n))), Scalar(-r*cos((CGAL_PI / n) + ((i * 2.0 * CGAL_PI) / n)))); } int main() diff --git a/Barycentric_coordinates_2/benchmark/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test_100_vertices.cpp b/Barycentric_coordinates_2/benchmark/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test_100_vertices.cpp index 261c4315dfb..1d568bf03db 100644 --- a/Barycentric_coordinates_2/benchmark/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test_100_vertices.cpp +++ b/Barycentric_coordinates_2/benchmark/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test_100_vertices.cpp @@ -2,6 +2,7 @@ // We test speed of mean value coordinates on a set of automatically generated // points inside a regular polygon with 100 vertices. We use inexact kernel. +#include #include #include #include @@ -28,12 +29,11 @@ void generate_regular_polygon(const int number_of_vertices, const double polygon { const int n = number_of_vertices; const double r = polygon_radius; - const double number_pi = 3.14159; vertices.resize(n); for(int i = 0; i < n; ++i) - vertices[i] = Point(Scalar(r*sin((number_pi / n) + ((i * 2.0 * number_pi) / n))), Scalar(-r*cos((number_pi / n) + ((i * 2.0 * number_pi) / n)))); + vertices[i] = Point(Scalar(r*sin((CGAL_PI / n) + ((i * 2.0 * CGAL_PI) / n))), Scalar(-r*cos((CGAL_PI / n) + ((i * 2.0 * CGAL_PI) / n)))); } int main() diff --git a/Barycentric_coordinates_2/benchmark/Barycentric_coordinates_2/Wachspress_coordinates/WP_speed_test_100_vertices.cpp b/Barycentric_coordinates_2/benchmark/Barycentric_coordinates_2/Wachspress_coordinates/WP_speed_test_100_vertices.cpp index 97468098ea0..0d28ec26fd2 100644 --- a/Barycentric_coordinates_2/benchmark/Barycentric_coordinates_2/Wachspress_coordinates/WP_speed_test_100_vertices.cpp +++ b/Barycentric_coordinates_2/benchmark/Barycentric_coordinates_2/Wachspress_coordinates/WP_speed_test_100_vertices.cpp @@ -2,6 +2,7 @@ // We test speed of Wachspress coordinates on a set of automatically generated // points inside a regular polygon with 100 vertices. We use inexact kernel. +#include #include #include #include @@ -28,12 +29,11 @@ void generate_regular_polygon(const int number_of_vertices, const double polygon { const int n = number_of_vertices; const double r = polygon_radius; - const double number_pi = 3.14159; vertices.resize(n); for(int i = 0; i < n; ++i) - vertices[i] = Point(Scalar(r*sin((number_pi / n) + ((i * 2.0 * number_pi) / n))), Scalar(-r*cos((number_pi / n) + ((i * 2.0 * number_pi) / n)))); + vertices[i] = Point(Scalar(r*sin((CGAL_PI / n) + ((i * 2.0 * CGAL_PI) / n))), Scalar(-r*cos((CGAL_PI / n) + ((i * 2.0 * CGAL_PI) / n)))); } int main() diff --git a/Generator/include/CGAL/point_generators_d.h b/Generator/include/CGAL/point_generators_d.h index 9661e647a42..9fc0b0b9193 100644 --- a/Generator/include/CGAL/point_generators_d.h +++ b/Generator/include/CGAL/point_generators_d.h @@ -18,6 +18,8 @@ #include #include +#include + #include #include @@ -56,11 +58,10 @@ generate_point() { for(int i=0; i_rnd.get_double(); a = std::sqrt( -2* std::log(1-a) ); double b=this->_rnd.get_double(); - b = std::cos(2*pi*b); + b = std::cos(2*CGAL_PI*b); coord[i]= a*b; norm += coord[i]*coord[i]; } @@ -104,11 +105,10 @@ generate_point() { for(int i=0; i_rnd.get_double(); a = std::sqrt( -2* std::log(1-a) ); double b=this->_rnd.get_double(); - b = std::cos(2*pi*b); + b = std::cos(2*CGAL_PI*b); coord[i]= a*b; norm += coord[i]*coord[i]; } diff --git a/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/scene.h b/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/scene.h index 5c2444aefc9..5693f0fbb30 100644 --- a/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/scene.h +++ b/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/scene.h @@ -18,9 +18,11 @@ #define cimg_display 0 // To avoid X11 or Windows-GDI dependency #include #endif -#include #include // std::pair #include + +#include +#include #include #include #include @@ -953,7 +955,7 @@ public: void append_star(const int nb_branches, const int density) { std::cerr << "append star..."; - const double deg_in_rad = 3.1415926535897932384626 / 180.0; + const double deg_in_rad = CGAL_PI / 180.0; const double incr = 180.0 / nb_branches; double angle = 0.0; const Point center(0.5, 0.5); @@ -970,7 +972,7 @@ public: void append_predefined_increasingly_sharp_angles(const int density, const double min_angle) { - const double deg_in_rad = 3.1415926535897932384626 / 180.0; + const double deg_in_rad = CGAL_PI / 180.0; double prev_angle = 0.0; double curr_angle = min_angle; double incr = min_angle; diff --git a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h index e80d6a9be52..4adb2278c15 100644 --- a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h +++ b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h @@ -16,6 +16,7 @@ #include +#include #include #include #include @@ -143,7 +144,7 @@ compute_denoise_projection( FT project_weight_sum = FT(0.0); Vector normal_sum = CGAL::NULL_VECTOR; - FT cos_sigma = cos(sharpness_angle / 180.0 * 3.1415926); + FT cos_sigma = cos(sharpness_angle * CGAL_PI / 180.0); FT sharpness_bandwidth = std::pow((CGAL::max)(1e-8, 1 - cos_sigma), 2); typename std::vector >::const_iterator diff --git a/Ridges_3/include/CGAL/Umbilics.h b/Ridges_3/include/CGAL/Umbilics.h index 6d1c2a017be..973184e60ab 100644 --- a/Ridges_3/include/CGAL/Umbilics.h +++ b/Ridges_3/include/CGAL/Umbilics.h @@ -13,15 +13,17 @@ #include +#include +#include +#include +#include +#include + +#include #include #include #include -#include -#include -#include -#include -#include namespace CGAL { @@ -230,7 +232,6 @@ compute_type(Umbilic& umb) { Vector_3 dir, dirnext, normal; double cosinus, angle=0, angleSum=0; - const double pi=3.141592653589793; vertex_descriptor v; typename std::list::const_iterator itb = umb.contour_list().begin(), itlast = --umb.contour_list().end(); @@ -266,9 +267,9 @@ compute_type(Umbilic& umb) else angle = -acos(cosinus); angleSum += angle; - if ((angleSum > (pi/2)) && (angleSum < (3*pi/2))) umb.umbilic_type() = HYPERBOLIC_UMBILIC ; - else if ((angleSum < (-pi/2)) && (angleSum > (-3*pi/2))) umb.umbilic_type() = ELLIPTIC_UMBILIC; - else if ((angleSum <= (pi/2)) && (angleSum >= (-pi/2))) return 0;//is not considered as an umbilic + if ((angleSum > (CGAL_PI/2)) && (angleSum < (3*CGAL_PI/2))) umb.umbilic_type() = HYPERBOLIC_UMBILIC ; + else if ((angleSum < (-CGAL_PI/2)) && (angleSum > (-3*CGAL_PI/2))) umb.umbilic_type() = ELLIPTIC_UMBILIC; + else if ((angleSum <= (CGAL_PI/2)) && (angleSum >= (-CGAL_PI/2))) return 0;//is not considered as an umbilic else umb.umbilic_type() = NON_GENERIC_UMBILIC; return 1; } diff --git a/Snap_rounding_2/include/CGAL/Snap_rounding_kd_2.h b/Snap_rounding_2/include/CGAL/Snap_rounding_kd_2.h index 82bcff43495..cf7b6c2def6 100644 --- a/Snap_rounding_2/include/CGAL/Snap_rounding_kd_2.h +++ b/Snap_rounding_2/include/CGAL/Snap_rounding_kd_2.h @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -394,7 +395,7 @@ public: Multiple_kd_tree(const Point_saved_pair_list & inp_points_list, int inp_number_of_trees, const Segment_list & seg_list) : - pi(3.1415), half_pi(1.57075), + pi(CGAL_PI), half_pi(0.5 * CGAL_PI), number_of_trees(inp_number_of_trees), input_points_list(inp_points_list) { diff --git a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_2_impl.h b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_2_impl.h index 580891ee897..413b9a9e5af 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_2_impl.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_2_impl.h @@ -22,9 +22,10 @@ #include #endif #include -#include +#include #include +#include #if defined(BOOST_MSVC) # pragma warning(push) @@ -1421,8 +1422,8 @@ double angle_wrt_X ( Point const& a, Point const& b ) double dx = to_double(b.x() - a.x() ) ; double dy = to_double(b.y() - a.y() ) ; double atan = std::atan2(dy,dx); - double rad = atan >= 0.0 ? atan : 2.0 * 3.141592653589793238462643 + atan ; - double deg = rad * 180.0 / 3.141592653589793238462643; + double rad = atan >= 0.0 ? atan : 2.0 * CGAL_PI + atan ; + double deg = rad * 180.0 / CGAL_PI; return deg ; }