Use CGAL_PI instead of hardcoding it

This commit is contained in:
Mael Rouxel-Labbé 2020-01-07 15:31:07 +01:00
parent 08ef100083
commit 3c7eb2c6b9
9 changed files with 33 additions and 27 deletions

View File

@ -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 <CGAL/number_type_config.h>
#include <CGAL/Real_timer.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Barycentric_coordinates_2/Discrete_harmonic_2.h>
@ -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()

View File

@ -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 <CGAL/number_type_config.h>
#include <CGAL/Real_timer.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Barycentric_coordinates_2/Mean_value_2.h>
@ -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()

View File

@ -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 <CGAL/number_type_config.h>
#include <CGAL/Real_timer.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Barycentric_coordinates_2/Wachspress_2.h>
@ -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()

View File

@ -18,6 +18,8 @@
#include <CGAL/generators.h>
#include <CGAL/number_type_basic.h>
#include <CGAL/number_type_config.h>
#include <cmath>
#include <vector>
@ -56,11 +58,10 @@ generate_point() {
for(int i=0; i<dimension; ++i) {
// normal distribution
//( a product of normal distib is a normal distrib in higher dim)
const double pi = 3.141592653589793238462643;
double a=this->_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<dimension; ++i) {
// normal distribution
const double pi = 3.141592653589793238462643;
double a=this->_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];
}

View File

@ -18,9 +18,11 @@
#define cimg_display 0 // To avoid X11 or Windows-GDI dependency
#include <CImg.h>
#endif
#include <CGAL/Random.h>
#include <utility> // std::pair
#include <vector>
#include <CGAL/number_type_config.h>
#include <CGAL/Random.h>
#include <CGAL/property_map.h>
#include <CGAL/value_type_traits.h>
#include <CGAL/compute_average_spacing.h>
@ -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;

View File

@ -16,6 +16,7 @@
#include <CGAL/disable_warnings.h>
#include <CGAL/number_type_config.h>
#include <CGAL/Search_traits_3.h>
#include <CGAL/Orthogonal_k_neighbor_search.h>
#include <CGAL/Point_set_processing_3/internal/neighbor_query.h>
@ -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<Pwn,CGAL_PSP3_DEFAULT_ALLOCATOR<Pwn> >::const_iterator

View File

@ -13,15 +13,17 @@
#include <CGAL/license/Ridges_3.h>
#include <CGAL/basic.h>
#include <CGAL/boost/graph/helpers.h>
#include <CGAL/number_type_config.h>
#include <CGAL/PolyhedralSurf_neighbors.h>
#include <CGAL/Kernel/global_functions_3.h>
#include <boost/shared_ptr.hpp>
#include <list>
#include <vector>
#include <math.h>
#include <CGAL/basic.h>
#include <CGAL/boost/graph/helpers.h>
#include <CGAL/PolyhedralSurf_neighbors.h>
#include <CGAL/Kernel/global_functions_3.h>
#include <boost/shared_ptr.hpp>
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<halfedge_descriptor>::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;
}

View File

@ -25,6 +25,7 @@
#include <CGAL/utility.h>
#include <CGAL/assertions.h>
#include <CGAL/Dimension.h>
#include <CGAL/number_type_config.h>
#include <boost/type_traits/is_pointer.hpp>
@ -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)
{

View File

@ -22,9 +22,10 @@
#include <boost/type_traits/detail/ice_not.hpp>
#endif
#include <boost/graph/adjacency_matrix.hpp>
#include <CGAL/Unique_hash_map.h>
#include <CGAL/number_type_config.h>
#include <CGAL/Real_timer.h>
#include <CGAL/Unique_hash_map.h>
#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 ;
}