diff --git a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/Barycentric_coordinates_2.txt b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/Barycentric_coordinates_2.txt index be72d546670..1133964c85c 100755 --- a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/Barycentric_coordinates_2.txt +++ b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/Barycentric_coordinates_2.txt @@ -54,14 +54,6 @@ We also do this for Segment and Triangle coordinates - `Barycentric_coordinates::Seg_coordinates_2` and - `Barycentric_coordinates::Tri_coordinates_2`. -The last five classes are intended to parallel the computation of coordinates for multiple points. These classes are parameterized by `CGAL::Polygon_2` class, they require a container with points, and they return an `std::vector` with coordinates - -- `Barycentric_coordinates::Segment_coordinates_parallel_2`, -- `Barycentric_coordinates::Triangle_coordinates_parallel_2`, -- `Barycentric_coordinates::Wachspress_coordinates_parallel_2`, -- `Barycentric_coordinates::Mean_value_coordinates_parallel_2`, and -- `Barycentric_coordinates::Discrete_harmonic_coordinates_parallel_2`. - \subsection gbc_int_compute_weights Computation of the weight functions Since all the closed-form generalized barycentric coordinates are normalized weight functions (See \ref gbc_theory section for more information), the base class is able to compute weights directly without normalization for a strictly interior query point. To do so, you can use the following function @@ -121,7 +113,7 @@ In the following example we create a random strictly convex polygon with 1000 ra \cgalExample{Barycentric_coordinates_2/Wachspress_coordinates_example.cpp} \subsection dh_example Discrete Harmonic coordinates example -In this example we are going to compute the set of Discrete Harmonic coordinates for a set of green (interior), red (boundary), and blue (exterior) points with respect to the unit square. We will also show how to accelerate computations using additional parameters of the function `compute()`. The used kernel is exact, and we use `std::list` as an output container. Since all the points are symmetric, it is easy to debug the correctness of the obtained coordinate values. Output iterator is `std::back_insert_iterator`. +In this example we are going to compute the set of Discrete Harmonic coordinates for a set of interior, boundary, and exterior points with respect to the unit square. We will also show how to accelerate computations using additional parameters of the function `compute()`. The used kernel is exact, and we use `std::list` as an output container. Since all the points are symmetric, it is easy to debug the correctness of the obtained coordinate values. Output iterator is `std::back_insert_iterator`. \anchor dh_coord_example \cgalFigureBegin{dh__example,discrete_harmonic_coordinates_example.png} @@ -166,7 +158,7 @@ Example's point pattern. Segment coordinates can be computed exactly if an exact data type is chosen. The segment itself, with respect to which we compute coordinates, must be not degenerate. If the both conditions are satisfied, the computation never breaks down. But, we have to do some clarification here. To compute coordinate functions, the user must be positive about a query point being exactly on the line \f$L\f$ supporting the segment. Since in many applications it is not the case, and a query point may lie very close but not exactly on this line, the class is able to handle this situation. \cgalFigureBegin{projection,projection.png} -Scalar projection \f$p'\f$ of the vector \f$p\f$ on the vector \f$q\f$. +Scalar projection \f$p'\f$ of the vector \f$p\f$ on the vector \f$q\f$. \cgalFigureEnd Let us imagine that some query point \f$v\f$ does not lie exactly on the line \f$L\f$, but it is of some distance \f$d\f$ away as it is shown in the figure above. If we want to compute Segment barycentric coordinate \f$b_1(v)\f$ with respect to the vertex \f$v_1\f$, we, first, find a scalar projection \f$p'\f$ of the vector \f$p\f$ on the vector \f$q\f$ and then normalize it by the length of \f$q\f$. It gives us Segment barycentric coordinate \f$b_1(v') = b_1(v)\f$ if \f$v\f$ lied exactly on the line. @@ -250,7 +242,7 @@ Since \f$\bar{w}_i\f$ is always positive, we have to append to it the proper sig Apart the most important requirement on barycentric coordinates to be as much as possible precise, it is very important for them to be as fast as possible to evaluate. These coordinate functions are used in many applications where they must be computed for millions of points and, thus, the real time usage of coordinates is crucial. When writing the code, we tried to fulfil this important requirement, and in this section we present the reader a few results about the computational time of the implemented coordinate functions. -The structure of the speed test that we run for all the functions consists of computing coordinate (or weight) values at \f$10^6-10^9\f$ strictly interior points with respect to some polygon (triangle or segment). At each iteration of the loop we create a query point, pass it to the function, and compute all the related coordinates. We run this loop 10 times in a row, and the time presented in the Table 1 is the arithmetic mean of all the trials. A typical example of the performed test for Triangle coordinates can be found below. This example also shows how to construct your own iterator and pass it to our class. In our example we create an iterator that writes coordinate values for each new query point over coordinate values of the previous point in the fixed-size standard C++ array, so that memory is allocated only once. +The structure of the speed test that we run for all the functions consists of computing coordinate (or weight) values at \f$10^8-10^{10}\f$ strictly interior points with respect to some polygon (triangle or segment). At each iteration of the loop we create a query point, pass it to the function, and compute all the related coordinates. We run this loop 10 times in a row, and the time presented in the Table 1 is the arithmetic mean of all the trials. A typical example of the performed test for Triangle coordinates can be found below. This example also shows how to construct your own iterator and pass it to our class. In our example we create an iterator that writes coordinate values for each new query point over coordinate values of the previous point in the fixed-size standard C++ array, so that memory is allocated only once. \cgalExample{Barycentric_coordinates_2/Triangle_coordinates_speed_test.cpp} @@ -260,175 +252,155 @@ The machine that has been used in all the tests is MacBook Pro 2011 with 2 GHz I
| Time to compute Segment and Triangle coordinates | +Time to compute Segment and Triangle coordinates (seconds) | |||||||
|---|---|---|---|---|---|---|---|---|
| Type of coordinates | Number of points | Number of coordinate values | -Time in seconds | ++ | Time \f$O(n)\f$ algorithm | |||
| Segment coordinates | -\f$10^9\f$ | -\f$2\cdot 10^9\f$ | +\f$10^{10}\f$ | +\f$2\cdot 10^{10}\f$ | + | 13.86494708 | ||
| Triangle coordinates | -\f$10^9\f$ | -\f$3\cdot 10^9\f$ | +\f$10^{10}\f$ | +\f$3\cdot 10^{10}\f$ | + | 13.91510820 | ||
| Time to compute coordinate functions on a unit square | +Time to compute weight functions on a unit square (seconds) | |||||||
| Type of coordinates | Number of points | Number of coordinate values | -Time in seconds | -|||||
| Wachspress coordinates | -\f$10^9\f$ | -\f$4\cdot 10^9\f$ | -- | |||||
| Discrete Harmonic coordinates | -\f$10^9\f$ | -\f$4\cdot 10^9\f$ | -- | |||||
| Mean Value coordinates | -\f$10^9\f$ | -\f$4\cdot 10^9\f$ | -- | |||||
| Time to compute weight functions on a unit square | -||||||||
| Type of weights | -Number of points | -Number of weight values | -Time in seconds | ++ | Time \f$O(n)\f$ algorithm | |||
| Wachspress weights | \f$10^9\f$ | \f$4\cdot 10^9\f$ | + | 47.25240803 | ||||
| Discrete Harmonic weights | \f$10^9\f$ | \f$4\cdot 10^9\f$ | + | 58.56583214 | ||||
| Mean Value weights | \f$10^9\f$ | \f$4\cdot 10^9\f$ | + | 97.41971302 | ||||
| Time to compute coordinate functions on a strictly convex polygon with 16 vertices | +Time to compute coordinate functions on a unit square (seconds) | |||||||
| Type of coordinates | Number of points | Number of coordinate values | -Time in seconds | +Time \f$O(n^2)\f$ algorithm | +Time \f$O(n)\f$ algorithm | |||
| Wachspress coordinates | -\f$10^8\f$ | -\f$16\cdot 10^8\f$ | -+ | \f$10^9\f$ | +\f$4\cdot 10^9\f$ | +48.64753795 | +64.24326611 | |
| Discrete Harmonic coordinates | -\f$10^8\f$ | -\f$16\cdot 10^8\f$ | -+ | \f$10^9\f$ | +\f$4\cdot 10^9\f$ | +61.93832940 | +78.09849691 | |
| Mean Value coordinates | -\f$10^8\f$ | -\f$16\cdot 10^8\f$ | -+ | \f$10^9\f$ | +\f$4\cdot 10^9\f$ | +99.83270693 | +113.8180611 | |
| Time to compute weight functions on a strictly convex polygon with 16 vertices | +Time to compute weight functions on a strictly convex polygon with 16 vertices (seconds) | |||||||
| Type of weights | +Type of coordinates | Number of points | -Number of weight values | -Time in seconds | +Number of coordinate values | ++ | Time \f$O(n)\f$ algorithm | |
| Wachspress weights | \f$10^8\f$ | \f$16\cdot 10^8\f$ | + | 20.44883299 | ||||
| Discrete Harmonic weights | \f$10^8\f$ | \f$16\cdot 10^8\f$ | + | 22.88397408 | ||||
| Mean Value weights | \f$10^8\f$ | \f$16\cdot 10^8\f$ | + | 39.10448194 | ||||
| Parallel computation along segment, triangle, and unit square | +Time to compute coordinate functions on a strictly convex polygon with 16 vertices (seconds) | |||||||
| Type of coordinates | Number of points | Number of coordinate values | -Time in seconds | -|||||
| Segment coordinates | -\f$10^6\f$ | -\f$2\cdot 10^6\f$ | -- | |||||
| Triangle coordinates | -\f$10^6\f$ | -\f$3\cdot 10^6\f$ | -+ | Time \f$O(n^2)\f$ algorithm | +Time \f$O(n)\f$ algorithm | |||
| Wachspress coordinates | -\f$10^6\f$ | -\f$4\cdot 10^6\f$ | -+ | \f$10^8\f$ | +\f$16\cdot 10^8\f$ | +37.88853598 | +23.22868419 | |
| Discrete Harmonic coordinates | -\f$10^6\f$ | -\f$4\cdot 10^6\f$ | -+ | \f$10^8\f$ | +\f$16\cdot 10^8\f$ | +39.69916701 | +25.71915221 | |
| Mean Value coordinates | -\f$10^6\f$ | -\f$4\cdot 10^6\f$ | -+ | \f$10^8\f$ | +\f$16\cdot 10^8\f$ | +58.91693497 | +41.49101996 | |
| Table 1 | +Table 1 | |||||||