diff --git a/.gitattributes b/.gitattributes index 761854cb90d..01186938f56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -398,6 +398,7 @@ Box_intersection_d/doc_tex/Box_intersection_d/fig/box_inters.eps -text svneol=un Box_intersection_d/doc_tex/Box_intersection_d/fig/box_inters.gif -text svneol=unset#image/gif Box_intersection_d/doc_tex/Box_intersection_d/fig/box_inters.pdf -text svneol=unset#application/pdf Box_intersection_d/test/Box_intersection_d/benchmark.plot -text svneol=native#application/postscript +Circular_kernel_3/examples/Circular_kernel_3/example_Circular_kernel_3 -text Convex_hull_2/demo/Convex_hull_2/help/index.html svneol=native#text/html Convex_hull_2/doc_tex/Convex_hull_2/saarhull.eps -text svneol=unset#application/postscript Convex_hull_2/doc_tex/Convex_hull_2/saarhull.gif -text svneol=unset#image/gif diff --git a/Circular_kernel_3/examples/Circular_kernel_3/example_Circular_kernel_3 b/Circular_kernel_3/examples/Circular_kernel_3/example_Circular_kernel_3 new file mode 100755 index 00000000000..939d254620d Binary files /dev/null and b/Circular_kernel_3/examples/Circular_kernel_3/example_Circular_kernel_3 differ diff --git a/Circular_kernel_3/examples/Circular_kernel_3/example_Circular_kernel_3.C b/Circular_kernel_3/examples/Circular_kernel_3/example_Circular_kernel_3.C new file mode 100644 index 00000000000..1619a29edea --- /dev/null +++ b/Circular_kernel_3/examples/Circular_kernel_3/example_Circular_kernel_3.C @@ -0,0 +1,86 @@ +#include +#include +#include +#include +#include +#include +#include + +typedef CGAL::Quotient< CGAL::MP_Float > NT; +typedef CGAL::Cartesian Linear_k1; +typedef CGAL::Algebraic_kernel_for_spheres_2_3 Algebraic_k1; +typedef CGAL::Spherical_kernel_3 SK; +typedef SK::FT FT; +typedef SK::Sphere_3 Sphere_3; +typedef SK::Circle_3 Circle_3; +typedef SK::Intersect_3 Intersect_3; +typedef SK::Construct_sphere_3 Construct_sphere_3; +typedef SK::AK AK; +typedef AK::Polynomial_for_spheres_2_3 Polynomial_for_spheres_2_3; + +int main() { + + Intersect_3 theIntersect_3 = SK().intersect_3_object(); + Construct_sphere_3 theConstruct_sphere_3 = SK().construct_sphere_3_object(); + + CGAL::Random generatorOfgenerator; + int random_seed = generatorOfgenerator.get_int(0, 123456); + CGAL::Random theRandom(random_seed); + int count = 0; + double mean = 0; + for(int i=0; i<10000; i++) { + double x1 = theRandom.get_double(0.0,5.0); + double y1 = theRandom.get_double(0.0,5.0); + double z1 = theRandom.get_double(0.0,5.0); + double r = 1.0; + double x2 = theRandom.get_double(0.0,5.0); + double y2 = theRandom.get_double(0.0,5.0); + double z2 = theRandom.get_double(0.0,5.0); + Sphere_3 s1 = theConstruct_sphere_3(Polynomial_for_spheres_2_3(FT(x1),FT(y1),FT(z1),FT(r))); + Sphere_3 s2 = theConstruct_sphere_3(Polynomial_for_spheres_2_3(FT(x2),FT(y2),FT(z2),FT(r))); + std::vector< CGAL::Object > intersection_1; + theIntersect_3(s1, s2, std::back_inserter(intersection_1)); + if(intersection_1.size() > 0) { + count++; + Circle_3 c; + if(assign(c,intersection_1[0])) { + mean += std::sqrt(CGAL::to_double(c.squared_radius())); + } + } + } + + std::cout << "The approximate probability that 2 spheres with radius 1" + << std::endl; + std::cout << "choosen (uniformly) randomly on a 5x5x5 box intersect is: " + << ((double)count)/((double)(10000)) << std::endl; + std::cout << "The mean size of the radius of the intersection circle is: " + << (mean / ((double)count)) << std::endl << std::endl; + + count = 0; + + for(int i=0; i<10000; i++) { + double x1 = theRandom.get_double(0.0,5.0); + double y1 = theRandom.get_double(0.0,5.0); + double z1 = theRandom.get_double(0.0,5.0); + double r = 1.0; + double x2 = theRandom.get_double(0.0,5.0); + double y2 = theRandom.get_double(0.0,5.0); + double z2 = theRandom.get_double(0.0,5.0); + double x3 = theRandom.get_double(0.0,5.0); + double y3 = theRandom.get_double(0.0,5.0); + double z3 = theRandom.get_double(0.0,5.0); + Sphere_3 s1 = theConstruct_sphere_3(Polynomial_for_spheres_2_3(FT(x1),FT(y1),FT(z1),FT(r))); + Sphere_3 s2 = theConstruct_sphere_3(Polynomial_for_spheres_2_3(FT(x2),FT(y2),FT(z2),FT(r))); + Sphere_3 s3 = theConstruct_sphere_3(Polynomial_for_spheres_2_3(FT(x3),FT(y3),FT(z3),FT(r))); + std::vector< CGAL::Object > intersection_1; + theIntersect_3(s1, s2, s3, std::back_inserter(intersection_1)); + if(intersection_1.size() > 0) count++; + } + + std::cout << "The approximate probability that 3 spheres with radius 1" + << std::endl; + std::cout << "choosen (uniformly) randomly on a 5x5x5 box intersect is: " + << ((double)count)/((double)(10000)) << std::endl; + + return 0; +} diff --git a/Circular_kernel_3/examples/Circular_kernel_3/makefile b/Circular_kernel_3/examples/Circular_kernel_3/makefile new file mode 100644 index 00000000000..90252693c4a --- /dev/null +++ b/Circular_kernel_3/examples/Circular_kernel_3/makefile @@ -0,0 +1,61 @@ +# Created by the script create_makefile +# This is the makefile for compiling a CGAL application. + +#---------------------------------------------------------------------# +# include platform specific settings +#---------------------------------------------------------------------# +# Choose the right include file from the /make directory. + +# CGAL_MAKEFILE = ENTER_YOUR_INCLUDE_MAKEFILE_HERE +include $(CGAL_MAKEFILE) + +#---------------------------------------------------------------------# +# compiler flags +#---------------------------------------------------------------------# + +CXXFLAGS = \ + -DNDEBUG \ + -O2 \ + -I/user/pmachado/home/CGAL_I/include \ + -I../../include\ + -I../../../Algebraic_kernel_for_spheres/include \ + $(TESTSUITE_CXXFLAGS) \ + $(EXTRA_FLAGS) \ + $(CGAL_CXXFLAGS) \ + $(LONG_NAME_PROBLEM_CXXFLAGS) + # -I../../../synaps \ + +#---------------------------------------------------------------------# +# linker flags +#---------------------------------------------------------------------# + +LIBPATH = \ + $(TESTSUITE_LIBPATH) \ + $(CGAL_LIBPATH) + +LDFLAGS = \ + $(TESTSUITE_LDFLAGS) \ + $(LONG_NAME_PROBLEM_LDFLAGS) \ + $(CGAL_LDFLAGS) + +#---------------------------------------------------------------------# +# target entries +#---------------------------------------------------------------------# + +all: \ + example_Circular_kernel_3$(EXE_EXT) + +example_Circular_kernel_3$(EXE_EXT): example_Circular_kernel_3$(OBJ_EXT) + $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)example_Circular_kernel_3 example_Circular_kernel_3$(OBJ_EXT) $(LDFLAGS) + + +clean: \ + example_Circular_kernel_3.clean + +#---------------------------------------------------------------------# +# suffix rules +#---------------------------------------------------------------------# + +.C$(OBJ_EXT): + $(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) $< +