diff --git a/Circular_kernel_2/doc_tex/Circular_kernel_2/CK.tex b/Circular_kernel_2/doc_tex/Circular_kernel_2/CK.tex index b2715dde2bb..dca5336af36 100644 --- a/Circular_kernel_2/doc_tex/Circular_kernel_2/CK.tex +++ b/Circular_kernel_2/doc_tex/Circular_kernel_2/CK.tex @@ -63,13 +63,18 @@ that is based on similar techniques as %benchmarking should still be done and further optimizations will be %provided for future releases.} -\section{Example} +\section{Examples} -This example shows how to construct circles or circular arcs from -points, and how to compute intersections between them. +The first example shows how to construct circles or circular arcs from +points, and how to compute intersections between them using the global +function. \ccIncludeExampleCode{Circular_kernel_2/intersecting_arcs.cpp} +The following example shows how to use a functor of the kernel. + +\ccIncludeExampleCode{Circular_kernel_2/functor_has_on.cpp} + \section{Design and Implementation History} The first pieces of prototype code were comparisons of algebraic diff --git a/Circular_kernel_2/examples/Circular_kernel_2/functor_has_on.cpp b/Circular_kernel_2/examples/Circular_kernel_2/functor_has_on.cpp index ec0bcbe3a04..ba1975046a0 100644 --- a/Circular_kernel_2/examples/Circular_kernel_2/functor_has_on.cpp +++ b/Circular_kernel_2/examples/Circular_kernel_2/functor_has_on.cpp @@ -8,20 +8,21 @@ typedef CGAL::Circular_arc_2 Circular_arc_2; int main() { - int n = 0; - Circular_arc_2 c = Circular_arc_2(Point_2(10,0), Point_2(5,5), Point_2(0, 0)); - for(int i = 0; i <= 10; i++) { - for(int j = 0; j <= 10; j++) { - Point_2 p = Point_2(i, j); - if(Circular_k().has_on_2_object()(c,p)) { - n++; - std::cout << "(" << i << "," << j << ")" << std::endl; - } - } - } - std::cout << "There are " << n << " points in the [0,..,10]x[0,..,10] " << - "grid on the circular" << std::endl - << " arc defined counterclockwisely by the points (0,0), (5,5), (10,0)" - << std::endl << "See the points above." << std::endl; + int n = 0; + Circular_arc_2 c = Circular_arc_2(Point_2(10,0), Point_2(5,5), Point_2(0, 0)); + + for(int i = 0; i <= 10; i++) { + for(int j = 0; j <= 10; j++) { + Point_2 p = Point_2(i, j); + if(Circular_k().has_on_2_object()(c,p)) { + n++; + std::cout << "(" << i << "," << j << ")" << std::endl; + } + } + } + std::cout << "There are " << n << " points in the [0,..,10]x[0,..,10] " + << "grid on the circular" << std::endl + << " arc defined counterclockwisely by the points (0,0), (5,5), (10,0)" + << std::endl << "See the points above." << std::endl; return 0; }; diff --git a/Circular_kernel_2/examples/Circular_kernel_2/intersecting_arcs.cpp b/Circular_kernel_2/examples/Circular_kernel_2/intersecting_arcs.cpp index db9448e123d..be4cc87a88f 100644 --- a/Circular_kernel_2/examples/Circular_kernel_2/intersecting_arcs.cpp +++ b/Circular_kernel_2/examples/Circular_kernel_2/intersecting_arcs.cpp @@ -12,9 +12,11 @@ double prob_2() { CGAL::Random_points_in_square_2 g(1.0); double prob = 0.0; for (int i = 0; i < 10000; i++) { + Point_2 p1, p2, p3, p4, p5, p6; p1 = *g++; p2 = *g++; p3 = *g++; p4 = *g++; p5 = *g++; p6 = *g++; + // the pi's are points inherited from the Cartesian kernel Point_2, so, // the orientation predicate can be called on them if(CGAL::orientation(p1, p2, p3) != CGAL::COUNTERCLOCKWISE) std::swap(p1, p3); @@ -34,13 +36,14 @@ int main() { std::cout << "What is the probability that two arcs formed by" << std::endl; std::cout << "three random counterclockwise-oriented points on" << std::endl; - std::cout << "an unity square intersect? (wait a second please)" << std::endl; + std::cout << "an unit square intersect? (wait a second please)" << std::endl; std::cout << "The probability is: " << prob_2() << std::endl << std::endl; + std::cout << "And what about the probability that two circles formed by" << std::endl; std::cout << "three random counterclockwise-oriented points on" << std::endl; - std::cout << "an unity square intersect? (wait a second please)" << std::endl; + std::cout << "an unit square intersect? (wait a second please)" << std::endl; std::cout << "The probability is: " << prob_2() << std::endl; return 0; };