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 2dce21e8597..f72025bd5ba 100644 --- a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/Barycentric_coordinates_2.txt +++ b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/Barycentric_coordinates_2.txt @@ -1,43 +1,45 @@ + namespace CGAL { /*! \mainpage User Manual \anchor Chapter_2D_Generalized_Barycentric_Coordinates -\anchor chapterGeneralizedBarycentricCoordinates \cgalAutoToc \authors Dmitry Anisimov, David Bommes, Kai Hormann, and Pierre Alliez \section gbc_introduction Introduction -The package 2D Generalized Barycentric Coordinates offers an efficient and robust implementation of two-dimensional closed-form generalized barycentric coordinates defined for simple two-dimensional polygons. If coordinates with respect to multivariate scattered points instead of a polygon are required, please refer to natural neighbour coordinates from the package \ref chapinterpolation "2D and Surface Function Interpolation". +The package 2D Generalized Barycentric Coordinates offers an efficient and robust implementation of two-dimensional closed-form generalized barycentric coordinates defined for simple two-dimensional polygons. If coordinates with respect to multivariate scattered points instead of a polygon are required, please refer to natural neighbour coordinates from the package \ref PkgInterpolation2Summary "2D and Surface Function Interpolation". -In particular, the package includes an implementation of \ref wp_example "Wachspress", \ref mv_example "mean value", and \ref dh_example "discrete harmonic coordinates" and provides some extra functions to compute barycentric coordinates with respect to segments (\ref seg_example "segment coordinates") and triangles (\ref tri_example "triangle coordinates"). Section \ref gbc_theory gives a short introduction to the topic of barycentric coordinates. +In particular, the package includes an implementation of \ref wp_example "Wachspress", \ref mv_example "mean value", and \ref dh_example "discrete harmonic" coordinates and provides some extra functions to compute barycentric coordinates with respect to segments (\ref seg_example "segment coordinates") and triangles (\ref tri_example "triangle coordinates"). The section \ref gbc_theory gives a short introduction to the topic of barycentric coordinates. \section gbc_interface Interface -Each class to compute barycentric coordinates is parameterized by a traits class that specifies the types and geometric primitives to be used in the computation. The default traits class for the package is `CGAL::Barycentric_coordinates::Barycentric_traits_2` that presents the two-dimensional \cgal kernel and gives the default two-dimensional input to the class. +Each class that computes barycentric coordinates is parameterized by a traits class. This traits class specifies types and geometric primitives that are used in the computation and must be a model of the concept `BarycentricTraits_2`. -The main entry point to the component is an input iterator over the vertices of a polygon. The polygon's vertices must be ordered and can be of any type. However, internally the classes with coordinate functions use the type `CGAL::Point_2`, that is why an appropriate traits class that converts the user's type to the `CGAL::Point_2` must be provided. The same argument holds for query points. +The main entry point to the component is an input iterator over the vertices of a polygon. The polygon's vertices must follow clockwise or anticlockwise ordering and can be of any type. However, internally the classes use the type `CGAL::Point_2`, that is why an appropriate traits class that converts the user's type to `CGAL::Point_2` must be provided. The same argument holds for query points. -Mean value coordinates are the most generic coordinate functions in this package because they allow an arbitrary simple polygon as input. Wachspress and discrete harmonic coordinates are, by definition, limited to strictly convex polygons. Segment coordinates take as input any non-degenerate segment, and triangle coordinate functions allow an arbitrary non-degenerate triangle. +Mean value coordinates are the most generic coordinates in this package because they allow an arbitrary simple polygon as input. Wachspress and discrete harmonic coordinates are, by definition, limited to strictly convex polygons. Segment coordinates take as input any non-degenerate segment, and triangle coordinates allow an arbitrary non-degenerate triangle. -Any point in the plane may be taken as a query point. However, we do not recommend to use Wachspress and discrete harmonic coordinates with query points outside the closure of a polygon because at some of those points these coordinate functions are not well-defined as explained in Section \ref gbc_degeneracies. +Segment and triangle coordinates can be computed by using either a global function or creating the corresponding class. All other generalized coordinates can be computed by creating an instance of the class `CGAL::Barycentric_coordinates::Generalized_barycentric_coordinates_2` parameterized by an appropriate coordinate type that must be a model of the concept `BarycentricCoordinates_2`. -Once instantiated for some polygon, the coordinate functions can be computed multiple times for different query points with respect to all the vertices of the provided polygon. In order to compute basis functions, use the function `compute()`. In order to compute barycentric weights directly without normalization for a strictly interior query point, use the function `compute_weights()`. +Any point in the plane may be taken as a query point. However, we do not recommend to use Wachspress and discrete harmonic coordinates with query points outside the closure of a polygon because at some of those points these coordinates are not well-defined, as explained in the Section \ref gbc_degeneracies. -The output of the computation is a set of coordinate values at the current query point with respect to all the vertices of the polygon, and it can be stored in an arbitrary container providing an appropriate output iterator. In addition, all the classes return a pointer to the last stored element and status of the computation (boolean true or false). +Once instantiated for some polygon, the coordinates can be computed multiple times for different query points with respect to all the vertices of the provided polygon. Use the \ref PkgBarycentric_coordinates_2 "Reference Manual" for the detailed interface. + +The output of the computation is a set of coordinate values at the current query point with respect to all the vertices of the polygon. This output can be stored in an arbitrary container providing an appropriate output iterator. In addition, all the classes return a pointer to the last stored element and a status of the computation (Boolean true or false). \section gbc_examples Examples \subsection wp_example Wachspress Coordinates -In the following example we create a random strictly convex polygon with 1000 random interior points and compute Wachspress coordinates at all these points with respect to all the polygon's vertices. In order to do so, we create 1000 random points, then we take the convex hull of this set of points as our polygon, and compute Wachspress coordinates for all the randomly defined points. We use the `Simple_cartesian` kernel with double type and store the obtained coordinate values in `std::vector` container. The output iterator is `std::back_insert_iterator`, and it is handled automatically by the class. +In the following example we create 1000 random points, then we take the convex hull of this set of points as our polygon, and compute Wachspress coordinates at all the defined points. We use the `Simple_cartesian` kernel with double type as a traits class and store obtained coordinate values in a container of the type `std::vector`. The output iterator is `std::back_insert_iterator`. \cgalExample{Barycentric_coordinates_2/Wachspress_coordinates_example.cpp} \subsection dh_example Discrete Harmonic Coordinates -In this example we compute discrete harmonic coordinates for a set of interior, boundary, and exterior points with respect to the unit square. We also show how to accelerate computations using additional parameters of the function `compute()`. The used kernel is exact, and we use `std::vector` as an output container. Since all the points are symmetric, it is easy to debug the correctness of the obtained coordinate values. The output iterator is `std::back_insert_iterator`. +In this example we compute discrete harmonic coordinates for a set of green (interior), red (boundary), and blue (exterior) points with respect to a unit square. We also show how to specify the location of a query point using additional function parameters. The used kernel is exact, and we use an output container of the type `std::vector`. Since all the points are symmetric, it is easy to debug the correctness of the obtained coordinate values. The output iterator is `std::back_insert_iterator`. \anchor dh_coord_example \cgalFigureBegin{dh__example,discrete_harmonic_coordinates_example.png} @@ -47,7 +49,7 @@ Example's point pattern. \cgalExample{Barycentric_coordinates_2/Discrete_harmonic_coordinates_example.cpp} \subsection mv_example Mean Value Coordinates -This is an example that shows how to compute mean value coordinates for a set of green points in the star-shaped polygon. We note that this type of coordinates is well-defined for such a concave polygon while Wachspress and discrete harmonic coordinates are not. However, it may give some negative coordinate values for points outside the kernel. We use inexact data type, an `std::vector` container, and the std::back_insert_iterator to compute and store the resulting coordinate values. +This is an example that shows how to compute mean value coordinates for a set of green points in a star-shaped polygon. We note that this type of coordinates is well-defined for such a concave polygon while Wachspress and discrete harmonic coordinates are not. However, it may give negative coordinate values for points outside the polygon's kernel (shown in red). We use an inexact data type, an output container of the type `std::vector`, and an output iterator of the type std::back_insert_iterator to compute, access, and store the resulting coordinate values. We also show how to choose different algorithms to compute generalized barycentric coordinates (one is more precise while the other is faster). \anchor mv_coord_example \cgalFigureBegin{mv__example,mean_value_coordinates_example.png} @@ -57,7 +59,7 @@ Example's point pattern. \cgalExample{Barycentric_coordinates_2/Mean_value_coordinates_example.cpp} \subsection tri_example Triangle Coordinates -In this example we show how to use the class `CGAL::Barycentric_coordinates::Triangle_coordinates_2` with the `Simple_cartesian` kernel for a double type. We compute coordinates for three sets of points: interior, boundary, and exterior. Note that some of the coordinate values for the exterior points are negative. We use a standard `std::vector` container and the `std::insert_iterator` to access and store the resulting values. +In this example we show how to use the class `CGAL::Barycentric_coordinates::Triangle_coordinates_2` with the `Simple_cartesian` kernel for double type. We compute coordinates for three sets of points: interior (green), boundary (red), and exterior (blue). Note that some of the coordinate values for the exterior points are negative. We use a standard container of the type `std::vector` and `std::insert_iterator` to access and store the resulting coordinate values. \anchor tri_coord_example \cgalFigureBegin{tri__example,triangle_coordinates_example.png} @@ -67,7 +69,7 @@ Example's point pattern. \cgalExample{Barycentric_coordinates_2/Triangle_coordinates_example.cpp} \subsection seg_example Segment Coordinates -This is a very simple and short example on how to use the class `CGAL::Barycentric_coordinates::Segment_coordinates_2`. We compute coordinate functions at three interior points along the segment \f$[v_0, v_1]\f$ and at two exterior points outside this segment along its supporting line. We use the exact kernel and return the coordinate values as a 2D point of the type `CGAL::Point_2`. Again, the symmetry of the query points allows us to see if there are any errors in the computation of the coordinates. +This is a simple example to show the use of the global function \ref seg_coord_global "CGAL::Barycentric_coordinates::compute_segment_coordinates_2()". We compute coordinates at three green points along the segment \f$[v_0, v_1]\f$ and at two blue points outside this segment but along its supporting line. We use the exact kernel and return coordinates as an array of two values. Again, the symmetry of the query points helps us to recognize errors that may have occured during the computation. \anchor seg_coord_example \cgalFigureBegin{seg__example,segment_coordinates_example.png} @@ -76,35 +78,55 @@ Example's point pattern. \cgalExample{Barycentric_coordinates_2/Segment_coordinates_example.cpp} +\subsection height_inter_example Height Interpolation for Terrain Modelling + +This is an advanced example that shows how to use generalized barycentric coordinates for height interpolation with applications to terrain modelling. It also shows how to use a non-default traits class with our package instead of a `Kernel` traits class. Suppose we know the boundary of three-dimensional piece of terrain that can be represented as a polygon with several three-dimensional vertices, where the third dimension gives the corresponding height. The task is to propagate the height from the known sample points on the boundary to the polygon's interior. This gives an approximate estimation of the terrain's surface in this region. + +\anchor terrain_example +\cgalFigureBegin{terrain__example,terrain.png} +A 2D polygon with 50 vertices representing a piece of terrain with convex and concave parts. The height is not shown. +\cgalFigureEnd + +In this example we project a three-dimensional polygon orthogonally onto the two-dimensional plane using the class `CGAL::Projection_traits_xy_3`, triangulate its interior using the class `CGAL::Delaunay_mesher_2`, and compute mean value coordinates for all the obtained points with respect to all the polygon's vertices. Finally, we interpolate the height data from the polygon's boundary to its interior using the computed coordinates and the global interpolation function from the package \ref PkgInterpolation2Summary "2D and Surface Function Interpolation". + +\cgalExample{Barycentric_coordinates_2/Height_interpolation_for_terrain_modelling_example.cpp} + +As a result we get a smooth function inside the polygon that approximates the underlying terrain's surface. + +\anchor terrain_example +\cgalFigureBegin{terrain__inter__example,terrain_interpolated.png} +The interpolated data. The colour bar represents the corresponding height. +\cgalFigureEnd + \section gbc_degeneracies Degeneracies and Special Cases \anchor compute_seg_coord \subsection gbc_deg_segment_coordinates Segment Coordinates -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 both conditions are satisfied, then the computation never breaks down. However, to compute coordinate functions, the user must be sure about a query point being exactly on the line \f$L\f$ supporting the segment. Since in many applications this 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. +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 non-degenerate. If both conditions are satisfied, then the computation never fails. However, to compute coordinates, the user must be sure about the query point being exactly on the line \f$L\f$ supporting the segment. Since in many applications this is not the case, and a query point may lie very close but not exactly on this line, the class is also able to handle this situation. \cgalFigureBegin{projection,projection.png} -The scalar projection \f$p'\f$ of the vector \f$p\f$ onto the vector \f$q\f$. +The orthogonal projection \f$p'\f$ of the vector \f$p\f$ (green) onto the vector \f$q\f$ (red). \cgalFigureEnd -Suppose that some query point \f$v\f$ does not lie exactly on the line \f$L\f$, but is some distance \f$d\f$ away as shown in the figure above. If we want to compute the segment barycentric coordinate \f$b_1(v)\f$ with respect to the vertex \f$v_1\f$, we first find the scalar projection \f$p'\f$ of the vector \f$p\f$ onto the vector \f$q\f$ and then normalize it by the length of \f$q\f$. This gives the segment barycentric coordinate \f$b_1(v') = b_1(v)\f$ if \f$v\f$ lies exactly on the line. +Suppose that some query point \f$v\f$ does not lie exactly on the line \f$L\f$, but is some distance \f$d\f$ away as shown in the figure above. If we want to compute the segment barycentric coordinate \f$b_1(v)\f$ with respect to the vertex \f$v_1\f$, we first find the orthogonal projection \f$p'\f$ of the vector \f$p\f$ onto the vector \f$q\f$ and then normalize it by the length of \f$q\f$. This gives the segment barycentric coordinate \f$b_1(v') = b_1(v)\f$ if \f$v\f$ lies exactly on the line. -\b Warning: Do not abuse the feature described above because it does not give correct segment barycentric coordinates for the point \f$v\f$ but rather those for \f$v'\f$. Moreover, segment barycentric coordinates for the point \f$v\f$ being not exactly on \f$L\f$ do not exist. But, if the non-zero distance \f$d\f$ is due to some numerical instability when computing the location of the point \f$v\f$ or any other problem which causes the point to be not exactly on the line, the final segment barycentric coordinates will be, at least approximately, correct. +\b Warning: do not abuse the feature described above because it does not give correct segment barycentric coordinates for the point \f$v\f$ but rather those for \f$v'\f$. Moreover, segment barycentric coordinates for a point \f$v\f$, which does not lie exactly on the line \f$L\f$, do not exist. But if the non-zero distance \f$d\f$ is due to some numerical instability when computing the location of the point \f$v\f$ or any other problem, which causes the point to be not exactly on the line, the final segment coordinates will be, at least approximately, correct. -With inexact data types, these coordinates give the correct result up to the precision of the chosen type. +With inexact data types, the resulting coordinate values are correct up to the precision of the chosen type. \subsection gbc_deg_triangular_coordinates Triangle Coordinates These coordinates can be computed exactly if an exact data type is chosen, for any query point in the plane and with respect to any non-degenerate triangle. No special cases are handled. The computation always gives the correct result. The notion of correctness depends on the precision of the used data type. Note that for exterior points some coordinate values will be negative. \subsection gbc_deg_wachspress_coordinates Wachspress Coordinates -Wachspress coordinates are well-defined in the closure of any strictly convex polygon. Therefore, for any query point from the polygon's closure with an exact data type, these coordinates are computed exactly and no false result is expected. For inexact data types, the resulting precision of the computation is due to the involved algorithm and chosen data type. In the following paragraph we discuss two available algorithms for computing Wachspress coordinate functions. One of them is `CGAL::Barycentric_coordinates::PRECISE`, the other is `CGAL::Barycentric_coordinates::FAST`. +Wachspress coordinates are well-defined in the closure of any strictly convex polygon. Therefore, for any query point from the polygon's closure with an exact data type, these coordinates are computed exactly and no false result is expected. For inexact data types, the resulting precision of the computation is due to the involved algorithm and chosen data type. In the following paragraph we discuss two available algorithms for computing Wachspress coordinates. One of them is `CGAL::Barycentric_coordinates::PRECISE`, the other is `CGAL::Barycentric_coordinates::FAST`. \anchor wp_polygon \cgalFigureBegin{wp__notations,wp_notations.png} Notation for Wachspress coordinates. \cgalFigureEnd -To compute Wachspress weights we follow \cite cgal:bc:fhk-gcbcocp-06 and use the formula +To compute Wachspress weights, we follow \cite cgal:bc:fhk-gcbcocp-06 and use the formula
\f$w_i = \frac{C_i}{A_{i-1}A_i}\f$
@@ -112,29 +134,30 @@ with \f$i = 1\dots n\f$ where \f$n\f$ is the number of the polygon's vertices. I
\f$b_i = \frac{w_i}{W^{wp}}\qquad\f$ with \f$\qquad W^{wp} = \sum_{j=1}^n w_j.\f$
-This formula becomes unstable when approaching to the boundary of the polygon (\f$\approx 1.0e-10\f$ and closer). To fix the problem we modify the weights \f$w_i\f$, +This formula becomes unstable when approaching the boundary of the polygon (\f$\approx 1.0e-10\f$ and closer). To fix the problem, we modify the weights \f$w_i\f$ as
\f$\bar{w}_i = C_i\prod_{j\not=i-1,i} A_j\f$.
-After the normalization as above, this gives us the precise algorithm to compute Wachspress coordinates but with the \f$O(n^2)\f$ performance only. The fast \f$O(n)\f$ algorithm uses the standard weights \f$w_i\f$. Note that mathematically this modification does not change the coordinates. +After the normalization as above, this gives us the precise algorithm to compute Wachspress coordinates but with \f$O(n^2)\f$ performance only. The fast \f$O(n)\f$ algorithm uses the standard weights \f$w_i\f$. Note that mathematically this modification does not change the coordinates. -It is known that for strictly convex polygons the denominator's zero set of the Wachspress coordinates (\f$W^{wp} = 0~\f$) is a curve, which (in many cases) lies quite far away from the polygon. Speaking precisely, it goes through the intersection points of the continuations of the polygon's edges. Therefore, computation of Wachspress coordinates outside the polygon is possible only at points that do not belong to this curve. +It is known that for strictly convex polygons the denominator's zero set of the Wachspress coordinates (\f$W^{wp} = 0~\f$) is a curve, which (in many cases) lies quite far away from the polygon. Speaking precisely, it interpolates the intersection points of the continuations of the polygon's edges. Therefore, the computation of Wachspress coordinates outside the polygon is possible only at points that do not belong to this curve. \cgalFigureBegin{zero__set,zero_set.png} -Zero set of the Wachspress coordinates' denominator \f$W^{WP}\f$ for a non-regular hexagon. +Zero set (red) of the Wachspress coordinates' denominator \f$W^{wp}\f$ for a non-regular hexagon. \cgalFigureEnd -\b Warning: We do not recommend to use Wachspress coordinates for exterior points! +\b Warning: we do not recommend to use Wachspress coordinates for exterior points! \subsection gbc_deg_discrete_harmonic_coordinates Discrete Harmonic Coordinates -Discrete harmonic coordinates have the same requirements as Wachspress coordinates. They are well-defined in the closure of any strictly convex polygon and, if an exact data type is chosen, they are computed exactly. But, unlike Wachspress basis functions, these coordinates are not necessarily positive. In particular, the weight function \f$w_i\f$ is positive if and only if \f$\alpha+\beta < \pi\f$ (see the figure below for notation). For inexact data types, the precision of the computation is due to the involved algorithm and chosen data type. Again, we describe two algorithms to compute the coordinate functions: one is precise and one is fast. +Discrete harmonic coordinates have the same requirements as Wachspress coordinates. They are well-defined in the closure of any strictly convex polygon and, if an exact data type is chosen, they are computed exactly. But, unlike Wachspress basis functions, these coordinates are not necessarily positive. In particular, the weight \f$w_i\f$ is positive if and only if \f$\alpha+\beta < \pi\f$ (see the figure below for notation). For inexact data types, the precision of the computation is due to the involved algorithm and chosen data type. Again, we describe two algorithms to compute the coordinates: one is precise and one is fast. +\anchor dh_polygon \cgalFigureBegin{dh__notations,dh_notations.png} Notation for discrete harmonic coordinates. \cgalFigureEnd -To compute discrete harmonic weights we follow \cite cgal:bc:fhk-gcbcocp-06 and use the formula +To compute discrete harmonic weights, we follow \cite cgal:bc:fhk-gcbcocp-06 and use the formula
\f$w_i = \frac{r_{i+1}^2A_{i-1}-r_i^2B_i+r_{i-1}^2A_i}{A_{i-1}A_i}\f$
@@ -142,110 +165,119 @@ with \f$i = 1\dots n\f$ where \f$n\f$ is the number of the polygon's vertices. I
\f$b_i = \frac{w_i}{W^{dh}}\qquad\f$ with \f$\qquad W^{dh} = \sum_{j=1}^n w_j.\f$
-This formula becomes unstable when approaching to the boundary of the polygon (\f$\approx 1.0e-10\f$ and closer). To fix the problem, similarly to the previous subsection, we modify the weights \f$w_i\f$ as +This formula becomes unstable when approaching the boundary of the polygon (\f$\approx 1.0e-10\f$ and closer). To fix the problem, similarly to the previous subsection, we modify the weights \f$w_i\f$ as
\f$\bar{w}_i = (r_{i+1}^2A_{i-1}-r_i^2B_i+r_{i-1}^2A_i)\prod_{j\not=i-1,i} A_j\f$.
-After the normalization as above, this gives us the precise algorithm to compute discrete harmonic coordinates but with the \f$O(n^2)\f$ performance only. The fast \f$O(n)\f$ algorithm uses the standard weights \f$w_i\f$. Again, mathematically this modification does not change the coordinates. +After the normalization as above, this gives the precise algorithm to compute discrete harmonic coordinates but with \f$O(n^2)\f$ performance only. The fast \f$O(n)\f$ algorithm uses the standard weights \f$w_i\f$. Again, mathematically this modification does not change the coordinates. -\b Warning: As for Wachspress coordinates, we do not recommend to use discrete harmonic coordinates for exterior points because the curve \f$W^{dh} = 0\f$ may have several components, and one of them always goes through the polygon's vertices. However, if you are sure that the query point does not belong to this curve, you can use them as in the \ref dh_example example. +\b Warning: as for Wachspress coordinates, we do not recommend to use discrete harmonic coordinates for exterior points because the curve \f$W^{dh} = 0\f$ may have several components, and one of them interpolates the polygon's vertices. However, if you are sure that the query point does not belong to this curve, you can compute the coordinates as shown in \ref dh_example " this example". \subsection gbc_deg_mean_value_coordinates Mean Value Coordinates -Unlike all the previous coordinates, mean value coordinates cannot be computed exactly due to an inevitable square root operation. Although, if an exact data type is used, the precision of the computation depends only on two \cgal functions: `CGAL::to_double()` and `CGAL::sqrt()`. On the other hand, mean value coordinates are well-defined everywhere in the plane for any simple polygon. +Unlike the previous coordinates, mean value coordinates cannot be computed exactly due to an inevitable square root operation. Although, if an exact data type is used, the default precision of the computation depends only on two \cgal functions: `CGAL::to_double()` and `CGAL::sqrt()`. On the other hand, mean value coordinates are well-defined everywhere in the plane for any simple polygon. In addition, if your traits class provides a more precise version of the square root function, the final precision of the computation with exact data types will depend only on the precision of that function. +\anchor mv_polygon \cgalFigureBegin{mv__notations,mv_notations.png} Notation for mean value coordinates. \cgalFigureEnd -For these coordinate functions we also have two algorithms: one is precise and one is fast. The first one works everywhere in the plane, and the precision of the computation depends only on the chosen data type. However, its limit is the standard double type which is used internally to compute the square root. This algorithm is based on the following weight formula from \cite cgal:bc:f-wmvc-14 +For these coordinates we also have two algorithms: one is precise and one is fast. The first one works everywhere in the plane, and the precision of the computation depends only on the chosen data type, including the remarks above. This algorithm is based on the following weight formula from \cite cgal:bc:f-wmvc-14
\f$w_i = \sigma_i\bar{w}_i\qquad\f$ with \f$\qquad\bar{w}_i = (r_{i-1}r_{i+1}-d_{i-1}d_{i+1})^{1/2}\prod_{j\not= i-1,i}(r_jr_{j+1} + d_jd_{j+1})^{1/2}\qquad\f$ where \f$\qquad r_i = \|d_i\|.\f$
-Since \f$\bar{w}_i\f$ is always positive, we have to append to it the proper sign \f$\sigma_i\f$ of the signed mean value weight function, which can be found efficiently (see the figures below). Basically, this weight function is always positive to the left from the red piecewise linear curve, and it is negative to the right from this curve moving in counterclockwise direction. +Since \f$\bar{w}_i\f$ is always positive, we have to append to it the proper sign \f$\sigma_i\f$ of the signed mean value weight, which can be found efficiently (see the figures below). Basically, this weight is always positive to the left of the red piecewise linear curve, and it is negative to the right of this curve, moving in anticlockwise direction. \cgalFigureBegin{mv__weight__signs,mv_weight_signs_convex.png,mv_weight_signs_concave.png} -Signs of the mean value weight \f$w_i\f$ depending on the region with respect to a convex \f$P\f$ and a concave \f$P'\f$ polygon. +Signs of the mean value weight \f$w_i\f$ depending on the region with respect to a convex polygon \f$P\f$ and a concave polygon \f$P'\f$. \cgalFigureEnd -After the normalization of these weights as before we obtain the precise \f$O(n^2)\f$ algorithm. The fast \f$O(n)\f$ algorithm uses the pseudocode from here. To compute weights \f$w_i\f$ without normalization we use formulas from the same pseudocode. Note that they are getting unstable if a query point is closer than \f$\approx 1.0e-10\f$ to the polygon's boundary, similarly to Wachspress and discrete harmonic coordinates. +After the normalization of these weights as before + +
\f$b_i = \frac{w_i}{W^{mv}}\qquad\f$ with \f$\qquad W^{mv} = \sum_{j=1}^n w_j\f$
+ +we obtain the precise \f$O(n^2)\f$ algorithm. The fast O(n) algorithm computes the weights \f$w_i\f$ using the pseudocode from here. These weights + +
\f$w_i = \frac{t_{i-1} + t_i}{r_i}\qquad\f$ with \f$\qquad t_i = \frac{\text{det}(d_i, d_{i+1})}{r_ir_{i+1} + d_id_{i+1}}\f$
+ +are also normalized. Note that they are unstable if a query point is closer than \f$\approx 1.0e-10\f$ to the polygon's boundary, similarly to Wachspress and discrete harmonic coordinates. \section gbc_performance Performance -Apart from the most important requirement on barycentric coordinates to be as precise as possible, 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 a few results about the computational time of the implemented coordinate functions. +Apart from the most important requirement on barycentric coordinates to be as precise as possible, it is very important for them to be as fast as possible to evaluate. These coordinates 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 a few results about the computation times of the implemented coordinates. -The structure of the speed test that we ran for all the functions consists of computing coordinate values (or weights) at >= 1 million strictly interior points with respect to some polygon (or 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 log-log scale plot at the end of the section is the arithmetic mean of all trials. A typical example of the performed test for triangle coordinates can be found below. This example also illustrates how to construct an iterator and pass it to the class. In the 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 ran for all functions consists of computing coordinate values (or weights) at >= 1 million strictly interior points with respect to some polygon (or 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 log-log scale plot at the end of the section is the arithmetic mean of all trials. A typical example of this performance test for triangle coordinates can be found below. This example also illustrates how to construct an iterator and pass it to the class. In this 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} -The time to compute coordinates depends on many factors such as memory allocation, input kernel, output container, number of points, and so on. In our tests we used the most standard C++ and \cgal features with minimum memory allocation. Therefore, the final time presented is the average time that can be expected without deep optimization but still with efficient memory allocation. It also means that it may vary depending on the usage of the package. +The time to compute coordinates depends on many factors such as memory allocation, input kernel, output container, number of points, etc. In our tests we used the most standard C++ and \cgal features with minimum memory allocation. Therefore, the final time presented is the average time that can be expected without deep optimization but still with efficient memory allocation. It also means that it may vary depending on the usage of the package. -The machine used in all the tests is a MacBook Pro 2011 with 2 GHz Intel Core i7 processor (2 cores) and 8 GB 1333 MHz DDR3 memory. The installed operating system is OS X 10.9 Maverick. In order to compile the speed test suite, we used the Clang 5.0 64bit compiler. The resulting timings can be found in the figure below. +For all tests we used a MacBook Pro 2011 with 2 GHz Intel Core i7 processor (2 cores) and 8 GB 1333 MHz DDR3 memory. The installed operating system was OS X 10.9 Maverick. In order to compile the speed test suite, we used the Clang 5.0 64bit compiler. The resulting timings can be found in the figure below. \cgalFigureBegin{time,time.png} -Time in seconds to compute \f$n\f$ coordinate functions for a polygon with \f$n\f$ vertices at 1 million points. Solid \f$O(n^2)\f$ and dashed \f$O(n)\f$ algorithms for Wachspress, discrete harmonic, and mean value coordinates. +Time in seconds to compute \f$n\f$ coordinate values for a polygon with \f$n\f$ vertices at 1 million points with the fast \f$O(n)\f$ algorithms (dashed) and the slow \f$0(n^2)\f$ algorithms (solid) for Wachspress (blue), discrete harmonic (red), and mean value (green) coordinates. \cgalFigureEnd -From the figure above it is easy to see that, when we have a polygon with a small number of vertices, the \f$O(n^2)\f$ algorithm is as fast as the \f$O(n)\f$ algorithm but, when we increase the number of vertices, the linear algorithm outperforms the squared one, as expected. One of the reasons for this to happen is because for a small number of vertices the operation of multiplication over \f$n-2\f$ elements inside the \f$O(n^2)\f$ algorithm, when computing weights, takes almost the same time as the corresponding operation of division in the \f$O(n)\f$ algorithm. For a polygon with many vertices this multiplication is much slower. +From the figure above it is easy to see that the \f$O(n^2)\f$ algorithm is as fast as the \f$O(n)\f$ algorithm if we have a polygon with a small number of vertices. But as the number of vertices is increased, the linear algorithm outperforms the squared one, as expected. One of the reasons for this behaviour is that for a small number of vertices the multiplications for \f$n-2\f$ elements inside the \f$O(n^2)\f$ algorithm with the fast \f$O(n)\f$ algorithms (dashed) and the slow \f$O(n^2)\f$ algorithms (solid) take almost the same time as the corresponding division in the \f$O(n)\f$ algorithm. For a polygon with many vertices this multiplication is much slower. \section gbc_implementation Implementation Details -The generic design of the package was developed in 2013 by Dmitry Anisimov and David Bommes with many useful comments by Kai Hormann and Pierre Alliez. The package consists of 10 classes, 3 enumerations, and one namespace. Appropriate iterators are used to provide an efficient access to data and pass them to one of the generic algorithms to compute coordinates. Once instantiated for a polygon (triangle, segment), the coordinate functions can be computed multiple times for different query points with respect to all the vertices of the provided polygon (triangle, segment). All the classes are fully templated and have a simple and similar design. For example, if the function to compute coordinates within one class is named `compute()`, it has the same name within all other classes. Yet, the number of functions can differ from one class to another. +The generic design of the package was developed in 2013 by Dmitry Anisimov and David Bommes with many useful comments by Kai Hormann and Pierre Alliez. The package consists of 6 classes, 2 enumerations, and one namespace. Appropriate iterators are used to provide an efficient access to data and to pass them to one of the generic algorithms for computing coordinates. Once instantiated for a polygon (triangle, segment), the coordinates can be computed multiple times for different query points with respect to all the vertices of the provided polygon (triangle, segment). All the classes are fully templated and have a simple and similar design. In particular, we follow the same naming convention for all functions. Yet, the number of functions can differ from one class to another. -The implemented algorithms for computing coordinates do not depend on a particular kernel, and all the coordinate functions can be computed exactly, if an exact kernel is used, apart from mean value coordinates. The latter coordinates involve a square root operation, which results in a slightly worse precision with exact data types due to temporal conversion into a floating point type. The computed coordinates can be stored in an arbitrary container if an appropriate output iterator is provided. +The implemented algorithms for computing coordinates do not depend on a particular kernel, and all the coordinates can be computed exactly, if an exact kernel is used, apart from mean value coordinates. The latter coordinates involve a square root operation, which results in a slightly worse precision with exact data types due to temporal conversion into a floating point type. The computed coordinates can be stored in an arbitrary container if an appropriate output iterator is provided. -It is worth noting that `CGAL::Barycentric_coordinates::Segment_coordinates_2` are used to compute generalized barycentric coordinates along the polygon's boundary. Hence, one can use a trick for segment coordinates from \ref gbc_degeneracies section if one is convinced that a point must lie exactly on the polygon's boundary but due to some numerical instabilities it does not. +It is worth noting that the class `CGAL::Barycentric_coordinates::Segment_coordinates_2` is used to compute generalized barycentric coordinates along the polygon's boundary. Hence, one can use the trick for segment coordinates from Section \ref gbc_degeneracies if one is convinced that a point must lie exactly on the polygon's boundary but due to some numerical instabilities it does not. -The package is implemented in a way that later, if needed, other two-dimensional generalized barycentric coordinates can be easily added to the package. +The package is implemented in a way that later, if needed, other two-dimensional generalized barycentric coordinates can be easily added to this package. \section gbc_theory Theory of 2D Generalized Barycentric Coordinates -In 1827, the famous German mathematician and theoretical astronomer August Ferdinand Möbius (1790--1868) proposed a method \cite cgal:bc:m-dbc-27 to find coordinates of a point in the plane with respect to the vertices of a triangle. These coordinates are called triangle barycentric coordinates (sometimes area coordinates), and they are widely used in a variety of applications. Some of these applications are linear interpolation over a triangle and a triangle inclusion test. The first one is used for so-called shading, and the second one arises in the rasterization step when an image in vector graphics format needs to be converted into a raster image. +In 1827, the German mathematician and theoretical astronomer August Ferdinand Möbius (1790--1868) proposed a method \cite cgal:bc:m-dbc-27 to find coordinates of a point in the plane with respect to the vertices of a triangle. These coordinates are called triangle barycentric coordinates (sometimes area coordinates), and they are widely used in a variety of applications. Some of these applications are linear interpolation over a triangle and a triangle inclusion test. The first one is used for so-called shading, and the second one arises in the rasterization step when an image in vector graphics format needs to be converted into a raster image. -Triangle barycentric coordinates have many important properties, including \em constant and linear precision, the Lagrange property, and positivity inside a triangle. These properties make these coordinates a unique tool in many scientific fields. If we restrict triangle coordinates to one of its edges and its supporting line, we get barycentric coordinates with respect to a segment. We call these coordinates \ref gbc_deg_segment_coordinates "segment coordinates" and compute them as explained \ref compute_seg_coord "here". +Triangle barycentric coordinates have many important properties, including \em constant and linear precision, the Lagrange property, and positivity inside a triangle. These properties make these coordinates a unique tool in many scientific fields. If we restrict triangle coordinates to one of the edges of a triangle and its supporting line, we get barycentric coordinates with respect to a segment and call them \ref compute_seg_coord "segment coordinates". -Let us show a couple of plots for the coordinates described above. To plot segment coordinates we take a line \f$y = 0.4\f$ and define \ref fig__seg__example "a segment" \f$[v_0, v_1]\f$ on this line. Then we sample this segment and compute segment coordinates for all the sample points. If we plot the segment coordinate function at all the defined points with respect to \f$v_1\f$, we get the blue line depicted in the figure below. It grows from zero at \f$v_0\f$ to one at \f$v_1\f$. +Let us show a couple of plots for the coordinates described above. To plot segment coordinates, we take a line \f$y = 0.4\f$ and define \ref fig__seg__example "a segment" \f$[v_0, v_1]\f$ on this line. Then we sample this segment and compute segment coordinates for all the sample points. If we plot the segment coordinate function at all the defined points with respect to the vertex \f$v_1\f$, we get the blue line depicted in the figure below. It grows from zero at the vertex \f$v_0\f$ to one at the vertex \f$v_1\f$. \cgalFigureBegin{seg__coord__interp,seg__coord__interp.png} -Segment coordinates for all the segment points with respect to \f$v_1 = (2.0,\ 0.4)\f$. +Segment coordinates (blue) for all the segment points (green) with respect to the vertex \f$v_1 = (2.0,\ 0.4)\f$. \cgalFigureEnd -If we want to plot triangle coordinates, we follow a similar approach. We take \ref fig__tri__example "a triangle" \f$[v_0, v_1, v_2]\f$ in the plane and sample its interior and boundary with a number of points. Once we have this sampling, we plot one of the triangle coordinate functions (here with respect to the third vertex of the triangle) at all the defined sample points. Likewise, we can plot the coordinate function with respect to the first or second vertex. The resulting function is a linear function (shown in the figure below) that grows from zero along the first edge \f$[v_0, v_1]\f$ to one at the chosen vertex \f$v_2\f$. +If we want to plot triangle coordinates, we follow a similar approach. We take \ref fig__tri__example "a triangle" \f$[v_0, v_1, v_2]\f$ in the plane and sample its interior and boundary with a number of points. Once we have this sampling, we plot one of the triangle coordinate functions (here with respect to the third vertex of the triangle) at all the defined sample points. Likewise, we can plot the coordinate function with respect to the first or second vertex. The resulting function is linear (shown in the figure below) that grows from zero along the first edge \f$[v_0, v_1]\f$ to one at the chosen vertex \f$v_2\f$. \cgalFigureBegin{tri__coord__interp,tri__coord__interp.png} -Triangle coordinates with respect to \f$v_2 = (1.0,\ 2.0)\f$. The colour bar indicates the range of values for the chosen coordinate function. +Triangle coordinates with respect to \f$v_2 = (1.0,\ 2.0)\f$. The colour bar indicates the range of values for the chosen coordinate. \cgalFigureEnd -Since many applications require to work with more complex planar geometric shapes than segments and triangles, it seems natural to investigate a generalized version of triangle coordinates with respect to arbitrary polygons. The first attempt was taken in 1975 by E. L. Wachspress \cite cgal:bc:w-rfeb-75, and the resulting generalized barycentric coordinates are now called Wachspress coordinates \cite cgal:bc:mlbd-gbcip-02. \ref gbc_deg_wachspress_coordinates "These coordinates" are well-defined for arbitrary strictly convex polygons and have all the properties of triangle coordinates \cite cgal:bc:fhk-gcbcocp-06. Unfortunately, they are not well-defined for weakly convex and concave polygons and break down in this setting. +Since many applications require to work with more complex planar geometric shapes than segments and triangles, it seems natural to investigate a generalized version of triangle coordinates with respect to arbitrary polygons. The first attempt was taken in 1975 by E. L. Wachspress \cite cgal:bc:w-rfeb-75, and the resulting generalized barycentric coordinates are now called Wachspress coordinates \cite cgal:bc:mlbd-gbcip-02. \ref gbc_deg_wachspress_coordinates "These coordinates" are well-defined for arbitrary strictly convex polygons and have all the properties of triangle coordinates \cite cgal:bc:fhk-gcbcocp-06. Unfortunately, they are not well-defined for weakly convex and concave polygons. -Analogously to the previous cases we want to plot the Wachspress coordinate function and see how it looks like. Let us choose a \ref wp_polygon "non-regular hexagon", slightly rotate it, and move one of its vertices towards the line through its two adjacent neighbours. We sample interior and boundary of this polygon as before and plot the coordinate function at all the defined sample points with respect to the vertex that we moved. We see that we get a smooth function, which is linear along edges and grows from zero to one, as the colour bar indicates. +Analogously to the previous cases, we want to plot the Wachspress coordinates and see how they look like. Let us choose a \ref wp_polygon "non-regular hexagon", slightly rotate it, and move one of its vertices towards the line through its two adjacent neighbours. We sample the interior and the boundary of this polygon as before and plot the coordinate function with respect to the vertex that we moved at all the sample points. We see that we get a smooth function, which is linear along all edges and grows from zero to one, as the colour bar indicates. \anchor wp_plot \cgalFigureBegin{wp__coord__interp,wp__coord__interp.png} -The Wachspress coordinate function with values from zero to one as the colour bar indicates. +The Wachspress coordinate function with respect to the indicated vertex with values from zero to one as the colour bar indicates. \cgalFigureEnd -Another type of generalized barycentric coordinates goes back to Pinkall and Polthier in 1993 \cite cgal:pp-cdmsc-93 and Eck et al. in 1995 \cite cgal:bc:eddhls-maam-95 in the context of \ref chapsurface_mesh_parameterization "triangle mesh parameterization". They are called discrete harmonic coordinates. \ref gbc_deg_discrete_harmonic_coordinates "These coordinates" are well-defined, similarly to Wachspress coordinates, for arbitrary strictly convex polygons and inherit all the properties of triangle coordinates apart from the positivity inside a polygon because they can take on negative values. Another interesting property of these coordinate functions is that they coincide with Wachspress coordinates for any polygon whose vertices lie on a common circle. +Another type of generalized barycentric coordinates goes back to Pinkall and Polthier in 1993 \cite cgal:pp-cdmsc-93 and Eck et al. in 1995 \cite cgal:bc:eddhls-maam-95 in the context of \ref PkgSurfaceParameterizationSummary "triangle mesh parameterization". They are called discrete harmonic coordinates. \ref gbc_deg_discrete_harmonic_coordinates "These coordinates" are well-defined, similarly to Wachspress coordinates, for arbitrary strictly convex polygons and inherit all the properties of triangle coordinates apart from the positivity inside a polygon because they can take on negative values \ref gbc_deg_discrete_harmonic_coordinates "for some polygons". Another interesting property of these coordinate functions is that they coincide with Wachspress coordinates for any polygon whose vertices lie on a common circle. -To plot discrete harmonic coordinates we take \ref wp_plot "the same polygon" as for Wachspress coordinates and plot the function with respect to the same vertex. Again, we get a smooth function, which is linear along edges and grows from zero to one. The distribution of colours in the plot shows the difference between discrete harmonic and Wachspress coordinates for the chosen polygon and vertex. +To plot discrete harmonic coordinates we take \ref wp_plot "the same polygon" as for Wachspress coordinates and plot the coordinate function with respect to the same vertex. Again, we get a smooth function, which is linear along all edges and grows from zero to one. Isolines in the plot show the difference between discrete harmonic and Wachspress coordinates for the chosen polygon and vertex. \anchor dh_plot \cgalFigureBegin{dh__coord__interp,dh__coord__interp.png} -The discrete harmonic coordinate function with values from zero to one as the colour bar indicates. +The discrete harmonic coordinate function with respect to the indicated vertex with values from zero to one as the colour bar indicates. \cgalFigureEnd -The last type of generalized barycentric coordinates that we discuss are mean value coordinates \cite cgal:f-mvc-03 proposed by M. Floater in 2003. Based on the mean value theorem, \ref gbc_deg_mean_value_coordinates "these coordinates", unlike Wachspress and discrete harmonic coordinates, are well-defined for arbitrary simple polygons, inherit all the properties of triangle coordinates for any convex polygon, and lack only the positivity property for general concave polygons. Hormann and Floater prove in \cite cgal:bc:hf-mvcapp-06 that these coordinates are positive inside the kernel of a star-shaped polygon. They are also positive in the closure of any quadrilateral. Like discrete harmonic weights, mean value weights are often used in the context of \ref chapsurface_mesh_parameterization "triangle mesh parameterization." +The last type of generalized barycentric coordinates that we discuss are mean value coordinates \cite cgal:f-mvc-03 proposed by M. Floater in 2003. Based on the mean value theorem, \ref gbc_deg_mean_value_coordinates "these coordinates", unlike Wachspress and discrete harmonic coordinates, are well-defined for arbitrary simple polygons, inherit all the properties of triangle coordinates for any convex polygon, and lack only the positivity property for general concave polygons. Hormann and Floater prove in \cite cgal:bc:hf-mvcapp-06 that these coordinates are positive inside the kernel of a star-shaped polygon. They are also positive in the closure of any quadrilateral. Like discrete harmonic weights, mean value weights are often used in the context of \ref PkgSurfaceParameterizationSummary "triangle mesh parameterization." -In order to show the particular behaviour of mean value coordinates with an application to concave polygons, we take \ref fig__mv__example "a star-shaped polygon" with ten vertices \f$[v_0, \dots, v_9]\f$, sample its interior and boundary, and plot the coordinate function with respect to the fourth vertex \f$v_3\f$. As the colour bar indicates, the obtained function grows from a slightly negative value to one at the chosen vertex. It is also smooth and linear along edges. +In order to show the particular behaviour of mean value coordinates with an application to concave polygons, we take \ref fig__mv__example "a star-shaped polygon" with ten vertices \f$[v_0, \dots, v_9]\f$, sample its interior and boundary, and plot the coordinate function with respect to the fourth vertex \f$v_3\f$. As the colour bar indicates, the obtained function grows from a slightly negative value to one at the chosen vertex. It is also smooth inside the polygon and linear along all edges. \cgalFigureBegin{mv__coord__interp,mv__coord__interp.png} Mean value coordinates with respect to \f$v_3\f$. The colour bar indicates the range of values for the chosen coordinate function. \cgalFigureEnd -Interesting fact: All the coordinates discussed in this section and implemented in the package come from one and the same family of generalized barycentric coordinates named 3-point family of coordinates \cite cgal:bc:fhk-gcbcocp-06. +Interesting fact: all the coordinates discussed in this section and implemented in the package come from one and the same family of generalized barycentric coordinates named 3-point family of coordinates \cite cgal:bc:fhk-gcbcocp-06. \section gbc_acknowledgments Acknowledgments -The authors wish to thank Teseo Schneider and Randolf Schaerfig for helpful comments and discussions. To create pictures for this manual the two programs were used: Geogebra and Matlab. +The authors wish to thank Teseo Schneider and Randolf Schaerfig for helpful comments and discussions. We also appreciate the great effort invested in this package by our reviewers Andreas Fabri and Sébastien Loriot. Finally, to create pictures for this manual, we used two programs: Geogebra and Matlab. */ diff --git a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/Concepts/BarycentricCoordinates_2.h b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/Concepts/BarycentricCoordinates_2.h index 3ae808b79c1..202bacbcf42 100644 --- a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/Concepts/BarycentricCoordinates_2.h +++ b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/Concepts/BarycentricCoordinates_2.h @@ -2,7 +2,7 @@ \ingroup PkgBarycentric_coordinates_2Concepts \cgalConcept -Requirements of the template parameter `Coordinate_2` for the class `CGAL::Barycentric_coordinates::Generalized_barycentric_coordinates_2` with a set of two-dimensional generalized barycentric coordinates. +Requirements of the template parameter `Coordinate_2` for the class `CGAL::Barycentric_coordinates::Generalized_barycentric_coordinates_2`. \cgalHasModel `CGAL::Barycentric_coordinates::Wachspress_2` \cgalHasModel `CGAL::Barycentric_coordinates::Mean_value_2` @@ -17,7 +17,7 @@ public: /// \name Creation /// @{ -/// Creates a class that implements behaviour of generalized barycentric coordinates for any query point that does not belong to the polygon's boundary. +/// Creates a class that implements generalized barycentric coordinates for any query point that does not belong to the polygon's boundary. /// The polygon is given by a range of vertices of the type `Traits::Point_2` stored in a container of the type `std::vector`. BarycentricCoordinates_2(const std::vector &vertices, const Traits &barycentric_traits); diff --git a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/PackageDescription.txt b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/PackageDescription.txt index 36c9b78a541..7e9f5cd12ef 100644 --- a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/PackageDescription.txt +++ b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/PackageDescription.txt @@ -4,12 +4,13 @@ /// \ingroup PkgBarycentric_coordinates_2 /*! + \addtogroup PkgBarycentric_coordinates_2 \cgalPkgDescriptionBegin{2D Generalized Barycentric Coordinates, PkgBarycentric_coordinates_2Summary} \cgalPkgPicture{barcoord_thumb.png} \cgalPkgSummaryBegin \cgalPkgAuthors{Dmitry Anisimov, David Bommes, Kai Hormann, and Pierre Alliez} -\cgalPkgDesc{The package 2D Generalized Barycentric Coordinates offers an efficient and robust implementation of two-dimensional closed-form generalized barycentric coordinates defined for simple two-dimensional polygons. If coordinates with respect to multivariate scattered points instead of a polygon are required, please refer to natural neighbour coordinates from the package \ref chapinterpolation "2D and Surface Function Interpolation".} +\cgalPkgDesc{The package 2D Generalized Barycentric Coordinates offers an efficient and robust implementation of two-dimensional closed-form generalized barycentric coordinates defined for simple two-dimensional polygons. If coordinates with respect to multivariate scattered points instead of a polygon are required, please refer to natural neighbour coordinates from the package 2D and Surface Function Interpolation.} \cgalPkgManuals{Chapter_2D_Generalized_Barycentric_Coordinates, PkgBarycentric_coordinates_2} \cgalPkgSummaryEnd \cgalPkgShortInfoBegin diff --git a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/dependencies b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/dependencies index 4d1aa80104b..5745e1fc6f3 100644 --- a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/dependencies +++ b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/dependencies @@ -1,9 +1,12 @@ Manual +Mesh_2 Polygon Kernel_23 Generator Convex_hull_2 Interpolation STL_Extension +Triangulation_2 +Profiling_tools Algebraic_foundations Surface_mesh_parameterization diff --git a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/examples.txt b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/examples.txt index 27854badb01..45ba51c2abe 100644 --- a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/examples.txt +++ b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/examples.txt @@ -1,8 +1,11 @@ /*! + \example Barycentric_coordinates_2/Segment_coordinates_example.cpp \example Barycentric_coordinates_2/Triangle_coordinates_example.cpp \example Barycentric_coordinates_2/Wachspress_coordinates_example.cpp \example Barycentric_coordinates_2/Mean_value_coordinates_example.cpp \example Barycentric_coordinates_2/Discrete_harmonic_coordinates_example.cpp \example Barycentric_coordinates_2/Triangle_coordinates_speed_test.cpp +\example Barycentric_coordinates_2/Height_interpolation_for_terrain_modelling_example.cpp + */ diff --git a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/fig/dh__coord__interp.png b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/fig/dh__coord__interp.png index ba381b2c827..9e815ccc907 100644 Binary files a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/fig/dh__coord__interp.png and b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/fig/dh__coord__interp.png differ diff --git a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/fig/terrain.png b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/fig/terrain.png new file mode 100644 index 00000000000..3cc08c968e2 Binary files /dev/null and b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/fig/terrain.png differ diff --git a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/fig/terrain_interpolated.png b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/fig/terrain_interpolated.png new file mode 100644 index 00000000000..9622682253a Binary files /dev/null and b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/fig/terrain_interpolated.png differ diff --git a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/fig/wp__coord__interp.png b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/fig/wp__coord__interp.png index 78515c4b3eb..a1c04108b49 100644 Binary files a/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/fig/wp__coord__interp.png and b/Barycentric_coordinates_2/doc/Barycentric_coordinates_2/fig/wp__coord__interp.png differ diff --git a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Discrete_harmonic_coordinates_example.cpp b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Discrete_harmonic_coordinates_example.cpp index 9b345741732..019715cbd72 100644 --- a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Discrete_harmonic_coordinates_example.cpp +++ b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Discrete_harmonic_coordinates_example.cpp @@ -1,9 +1,6 @@ -#include -#include #include - -// Namespace alias. -namespace BC = CGAL::Barycentric_coordinates; +#include +#include // Some convenient typedefs. typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; @@ -14,12 +11,11 @@ typedef Kernel::Point_2 Point; typedef std::vector Scalar_vector; typedef std::vector Point_vector; -typedef Point_vector::iterator InputIterator; typedef std::back_insert_iterator Vector_insert_iterator; typedef boost::optional Output_type; -typedef BC::Discrete_harmonic_2 Discrete_harmonic; -typedef BC::Generalized_barycentric_coordinates_2 Discrete_harmonic_coordinates; +typedef CGAL::Barycentric_coordinates::Discrete_harmonic_2 Discrete_harmonic; +typedef CGAL::Barycentric_coordinates::Generalized_barycentric_coordinates_2 Discrete_harmonic_coordinates; using std::cout; using std::endl; using std::string; @@ -37,7 +33,7 @@ int main() // Instantiate the class with discrete harmonic coordinates for the unit square defined above. Discrete_harmonic_coordinates discrete_harmonic_coordinates(vertices.begin(), vertices.end()); - // Print some information about the polygon and coordinate functions. + // Print some information about the polygon and coordinates. discrete_harmonic_coordinates.print_information(); // Instantiate the center point of the unit square. diff --git a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Height_interpolation_for_terrain_modelling_example.cpp b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Height_interpolation_for_terrain_modelling_example.cpp new file mode 100644 index 00000000000..90b256d74bf --- /dev/null +++ b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Height_interpolation_for_terrain_modelling_example.cpp @@ -0,0 +1,127 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Some convenient typedefs. + +// General. +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef CGAL::Projection_traits_xy_3 Projection; +// typedef Kernel Projection; + +typedef Projection::FT Scalar; +typedef Projection::Point_2 Point; + +typedef std::vector Scalar_vector; +typedef std::vector Point_vector; + +// Coordinates related. +typedef CGAL::Barycentric_coordinates::Mean_value_2 Mean_value; +typedef CGAL::Barycentric_coordinates::Generalized_barycentric_coordinates_2 Mean_value_coordinates; + +// Triangulation related. +typedef CGAL::Delaunay_mesh_face_base_2 Face_base; +typedef CGAL::Triangulation_vertex_base_2 Vertex_base; +typedef CGAL::Triangulation_data_structure_2 TDS; +typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; +typedef CGAL::Delaunay_mesh_size_criteria_2 Criteria; +typedef CGAL::Delaunay_mesher_2 Mesher; +typedef CDT::Finite_vertices_iterator Vertex_iterator; +typedef CDT::Vertex_handle Vertex_handle; + +// Interpolation related. +typedef CGAL::Interpolation_traits_2 Interpolation_traits; +typedef CGAL::Data_access< std::map > Value_access; + +// STD. +using std::cout; using std::endl; using std::string; + +int main() +{ + // Construct a polygon bounding a piece of three-dimensional terrain. + // Note that z-coordinate of each vertex represents the height function. + // Projection in 2D is done automatically by the Projection traits class. + Point_vector vertices; + const int number_of_vertices = 50; + vertices.resize(number_of_vertices); + + vertices[0] = Point(0.03, 0.05, 0.000); vertices[1] = Point(0.07, 0.04, 10.00); vertices[2] = Point(0.10, 0.04, 20.00); + vertices[3] = Point(0.14, 0.04, 30.00); vertices[4] = Point(0.17, 0.07, 40.00); vertices[5] = Point(0.19, 0.09, 50.00); + vertices[6] = Point(0.22, 0.11, 60.00); vertices[7] = Point(0.25, 0.11, 70.00); vertices[8] = Point(0.27, 0.10, 80.00); + vertices[9] = Point(0.30, 0.07, 90.00); vertices[10] = Point(0.31, 0.04, 100.0); vertices[11] = Point(0.34, 0.03, 110.0); + vertices[12] = Point(0.37, 0.02, 120.0); vertices[13] = Point(0.40, 0.03, 130.0); vertices[14] = Point(0.42, 0.04, 140.0); + vertices[15] = Point(0.44, 0.07, 150.0); vertices[16] = Point(0.45, 0.10, 160.0); vertices[17] = Point(0.46, 0.13, 170.0); + vertices[18] = Point(0.46, 0.19, 180.0); vertices[19] = Point(0.47, 0.26, 190.0); vertices[20] = Point(0.47, 0.31, 200.0); + vertices[21] = Point(0.47, 0.35, 210.0); vertices[22] = Point(0.45, 0.37, 220.0); vertices[23] = Point(0.41, 0.38, 230.0); + vertices[24] = Point(0.38, 0.37, 240.0); vertices[25] = Point(0.35, 0.36, 250.0); vertices[26] = Point(0.32, 0.35, 260.0); + vertices[27] = Point(0.30, 0.37, 270.0); vertices[28] = Point(0.28, 0.39, 280.0); vertices[29] = Point(0.25, 0.40, 290.0); + vertices[30] = Point(0.23, 0.39, 300.0); vertices[31] = Point(0.21, 0.37, 310.0); vertices[32] = Point(0.21, 0.34, 320.0); + vertices[33] = Point(0.23, 0.32, 330.0); vertices[34] = Point(0.24, 0.29, 340.0); vertices[35] = Point(0.27, 0.24, 350.0); + vertices[36] = Point(0.29, 0.21, 360.0); vertices[37] = Point(0.29, 0.18, 370.0); vertices[38] = Point(0.26, 0.16, 380.0); + vertices[39] = Point(0.24, 0.17, 390.0); vertices[40] = Point(0.23, 0.19, 400.0); vertices[41] = Point(0.24, 0.22, 410.0); + vertices[42] = Point(0.24, 0.25, 420.0); vertices[43] = Point(0.21, 0.26, 430.0); vertices[44] = Point(0.17, 0.26, 440.0); + vertices[45] = Point(0.12, 0.24, 450.0); vertices[46] = Point(0.07, 0.20, 460.0); vertices[47] = Point(0.03, 0.15, 470.0); + vertices[48] = Point(0.01, 0.10, 480.0); vertices[49] = Point(0.02, 0.07, 490.0); + + // Mesh this polygon. + + // Create a constrained Delaunay triangulation. + CDT cdt; + + std::vector vertex_handle(number_of_vertices); + + // Insert vertices of the polygon as our initial point set. + for(int i = 0; i < number_of_vertices; ++i) vertex_handle[i] = cdt.insert(vertices[i]); + + // Insert constraints - edges of the polygon - in order to mesh only the polygon's interior. + for(int i = 0; i < number_of_vertices; ++i) cdt.insert_constraint(vertex_handle[i], vertex_handle[(i + 1) % number_of_vertices]); + + Mesher mesher(cdt); + + // Set a criteria on how to mesh. + mesher.set_criteria(Criteria(0.01, 0.01)); + + // Mesh the polygon. + mesher.refine_mesh(); + + // Compute mean value coordinates and use them to interpolate data from the polygon's boundary to its interior. + + // Associate each point with the corresponding function value and coordinates. + std::map point_function_value; + std::vector< std::pair > point_coordinates(number_of_vertices); + + for(int i = 0; i < number_of_vertices; ++i) + point_function_value.insert(std::make_pair(vertices[i], vertices[i].z())); + + // Create an instance of the class with mean value coordinates. + Mean_value_coordinates mean_value_coordinates(vertices.begin(), vertices.end()); + + // Store all new interior points with interpolated data here. + std::vector points(cdt.number_of_vertices()); + + // Compute coordinates and interpolate the boundary data to the polygon's interior. + int index = 0; + for(Vertex_iterator vertex_iterator = cdt.finite_vertices_begin(); vertex_iterator != cdt.finite_vertices_end(); ++vertex_iterator) { + Scalar_vector coordinates; + + const Point &point = vertex_iterator->point(); + mean_value_coordinates(point, std::back_inserter(coordinates)); + + for(int j = 0; j < number_of_vertices; ++j) + point_coordinates[j] = std::make_pair(vertices[j], coordinates[j]); + + Scalar f = CGAL::linear_interpolation(point_coordinates.begin(), point_coordinates.end(), Scalar(1), Value_access(point_function_value)); + points[index] = Point(point.x(), point.y(), f); + cout << "The interpolated height with index " << index << " is " << f << ";" << endl; + ++index; + } + + return EXIT_SUCCESS; +} diff --git a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Mean_value_coordinates_example.cpp b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Mean_value_coordinates_example.cpp index cbe12a5e359..183f484d060 100644 --- a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Mean_value_coordinates_example.cpp +++ b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Mean_value_coordinates_example.cpp @@ -1,9 +1,6 @@ -#include #include #include - -// Namespace alias. -namespace BC = CGAL::Barycentric_coordinates; +#include // Some convenient typedefs. typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; @@ -14,12 +11,11 @@ typedef Kernel::Point_2 Point; typedef std::vector Scalar_vector; typedef std::vector Point_vector; -typedef Point_vector::iterator InputIterator; typedef std::back_insert_iterator Vector_insert_iterator; typedef boost::optional Output_type; -typedef BC::Mean_value_2 Mean_value; -typedef BC::Generalized_barycentric_coordinates_2 Mean_value_coordinates; +typedef CGAL::Barycentric_coordinates::Mean_value_2 Mean_value; +typedef CGAL::Barycentric_coordinates::Generalized_barycentric_coordinates_2 Mean_value_coordinates; using std::cout; using std::endl; using std::string; @@ -38,7 +34,7 @@ int main() // Instantiate the class with mean value coordinates for the polygon defined above. Mean_value_coordinates mean_value_coordinates(vertices.begin(), vertices.end()); - // Print some information about the polygon and coordinate functions. + // Print some information about the polygon and coordinates. mean_value_coordinates.print_information(); // Instantiate some interior points in the polygon. @@ -52,9 +48,10 @@ int main() // Compute mean value coordinates for all the defined interior points. // We speed up the computation using the O(n) algorithm called with the parameter CGAL::Barycentric_coordinates::FAST. + // The default one is CGAL::Barycentric_coordinates::PRECISE. const CGAL::Barycentric_coordinates::Type_of_algorithm type_of_algorithm = CGAL::Barycentric_coordinates::FAST; - // Use the parameter query_point_location = CGAL::Barycentric_coordinates::ON_BOUNDED_SIDE. + // We also speed up the computation by using the parameter query_point_location = CGAL::Barycentric_coordinates::ON_BOUNDED_SIDE. const CGAL::Barycentric_coordinates::Query_point_location query_point_location = CGAL::Barycentric_coordinates::ON_BOUNDED_SIDE; for(int i = 0; i < number_of_interior_points; ++i) { @@ -68,7 +65,7 @@ int main() cout << "Coordinate " << j + 1 << " = " << coordinates[i * number_of_vertices + j] << endl; } - // If we need only the unnormalized weights for the last point, we can compute them as follows. + // If we need only the unnormalized weights for some point (lets take the last one), we can compute them as follows. // Instantiate an std::vector to store weights. Scalar_vector weights; @@ -84,14 +81,14 @@ int main() // Invert this sum. const Scalar mv_inverted_denominator = Scalar(1) / mv_denominator; - // Output mean value weights. + // Output the mean value weights. const string status = (result ? "SUCCESS." : "FAILURE."); cout << endl << "Status of the weights' computation for the point " << last_point_index + 1 << ": " << status << endl; for(int j = 0; j < number_of_vertices; ++j) cout << "Weight " << j + 1 << " = " << weights[j] << endl; - // Now, if we normalize the weight functions, we recover values of the mean value coordinates for the last point computed earlier. + // Now, if we normalize the weights, we recover values of the mean value coordinates for the last point computed earlier. cout << endl << "After normalization, for the point " << last_point_index + 1 << " mean value coordinates are " << endl; for(int j = 0; j < number_of_vertices; ++j) cout << "Coordinate " << j + 1 << " = " << weights[j] * mv_inverted_denominator << endl; diff --git a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Segment_coordinates_example.cpp b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Segment_coordinates_example.cpp index 4b217bcb1dc..1107113cfba 100644 --- a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Segment_coordinates_example.cpp +++ b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Segment_coordinates_example.cpp @@ -1,5 +1,5 @@ -#include #include +#include // Namespace alias. namespace BC = CGAL::Barycentric_coordinates; @@ -17,8 +17,8 @@ using std::cout; using std::endl; using std::string; int main() { // Construct a segment. - const Point first_vertex = Point(0, Scalar(2)/Scalar(5)); - const Point second_vertex = Point(2, Scalar(2)/Scalar(5)); + const Point first_vertex(0, Scalar(2)/Scalar(5)); + const Point second_vertex(2, Scalar(2)/Scalar(5)); // Instantiate three interior and two exterior query points. const Point query_points[5] = { Point(Scalar(2) /Scalar(5), Scalar(2)/Scalar(5)), // interior query points @@ -29,13 +29,13 @@ int main() }; // Compute segment coordinates for all the defined points. - // We use a static function and return segment coordinates stored in the CGAL::cpp11::array data structure. + // We use a global function and return the segment coordinates stored in an array of the type CGAL::cpp11::array. cout << endl << "Computed segment coordinates are: " << endl << endl; for(int i = 0; i < 5; ++i) { const Pair pair = BC::compute_segment_coordinates_2(first_vertex, second_vertex, query_points[i], Kernel()); // Output both coordinates for each point. - cout << "Pair of coordinates # " << i + 1 << " = (" << pair[1] << ", " << pair[2] << ");" << endl; + cout << "Pair of coordinates # " << i + 1 << " = (" << pair[0] << ", " << pair[1] << ");" << endl; } cout << endl; diff --git a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Triangle_coordinates_example.cpp b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Triangle_coordinates_example.cpp index d0c71773091..1e4911be550 100644 --- a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Triangle_coordinates_example.cpp +++ b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Triangle_coordinates_example.cpp @@ -1,8 +1,5 @@ -#include #include - -// Namespace alias. -namespace BC = CGAL::Barycentric_coordinates; +#include // Some convenient typedefs. typedef CGAL::Simple_cartesian Kernel; @@ -12,16 +9,16 @@ typedef Kernel::Point_2 Point; typedef std::vector Scalar_vector; -typedef BC::Triangle_coordinates_2 Triangle_coordinates; +typedef CGAL::Barycentric_coordinates::Triangle_coordinates_2 Triangle_coordinates; using std::cout; using std::endl; using std::string; int main() { // Construct a triangle. - const Point first_vertex = Point(0.0f, 0.0f); - const Point second_vertex = Point(2.0f, 0.5f); - const Point third_vertex = Point(1.0f, 2.0f); + const Point first_vertex(0.0f, 0.0f); + const Point second_vertex(2.0f, 0.5f); + const Point third_vertex(1.0f, 2.0f); // Create an std::vector to store coordinates. Scalar_vector coordinates; @@ -29,7 +26,7 @@ int main() // Instantiate the class Triangle_coordinates_2 for the triangle defined above. Triangle_coordinates triangle_coordinates(first_vertex, second_vertex, third_vertex); - // Print some information about the triangle and coordinate functions. + // Print some information about the triangle and coordinates. triangle_coordinates.print_information(); // Instantiate some interior, boundary, and exterior query points for which we compute coordinates. diff --git a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Triangle_coordinates_speed_test.cpp b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Triangle_coordinates_speed_test.cpp index 98925608764..44422f1e68c 100644 --- a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Triangle_coordinates_speed_test.cpp +++ b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Triangle_coordinates_speed_test.cpp @@ -1,6 +1,6 @@ #include -#include #include +#include // Construct an iterator that takes as input the current data type and pointer to the first element in the standard C++ array. template @@ -21,9 +21,6 @@ public: inline void operator++ () { ++pointer; } }; -// Namespace alias. -namespace BC = CGAL::Barycentric_coordinates; - // Some convenient typedefs. typedef CGAL::Real_timer Timer; @@ -34,7 +31,7 @@ typedef Kernel::Point_2 Point; typedef overwrite_iterator Overwrite_iterator; -typedef BC::Triangle_coordinates_2 Triangle_coordinates; +typedef CGAL::Barycentric_coordinates::Triangle_coordinates_2 Triangle_coordinates; using std::cout; using std::endl; using std::string; @@ -55,9 +52,9 @@ int main() const Scalar y_step = one / Scalar(number_of_y_coordinates); // Create a right triangle with a slight offset from zero. - const Point first_vertex = Point(zero - x_step, zero - x_step); - const Point second_vertex = Point(two + y_step , zero - x_step); - const Point third_vertex = Point(zero - x_step, two + y_step ); + const Point first_vertex(zero - x_step, zero - x_step); + const Point second_vertex(two + y_step, zero - x_step); + const Point third_vertex(zero - x_step, two + y_step); // Instantiate the class Triangle_coordinates_2 for the right triangle defined above. Triangle_coordinates triangle_coordinates(first_vertex, second_vertex, third_vertex); diff --git a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Wachspress_coordinates_example.cpp b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Wachspress_coordinates_example.cpp index 5107b8398dd..743402c330b 100644 --- a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Wachspress_coordinates_example.cpp +++ b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/Wachspress_coordinates_example.cpp @@ -1,11 +1,8 @@ #include -#include -#include -#include #include - -// Namespace alias. -namespace BC = CGAL::Barycentric_coordinates; +#include +#include +#include // Some convenient typedefs. typedef CGAL::Simple_cartesian Kernel; @@ -18,10 +15,8 @@ typedef std::vector Point_vector; typedef CGAL::Creator_uniform_2 Creator; -typedef Point_vector::iterator InputIterator; - -typedef BC::Wachspress_2 Wachspress; -typedef BC::Generalized_barycentric_coordinates_2 Wachspress_coordinates; +typedef CGAL::Barycentric_coordinates::Wachspress_2 Wachspress; +typedef CGAL::Barycentric_coordinates::Generalized_barycentric_coordinates_2 Wachspress_coordinates; using std::cout; using std::endl; using std::string; @@ -46,7 +41,7 @@ int main() // Instantiate the class with Wachspress coordinates for the convex polygon defined above. Wachspress_coordinates wachspress_coordinates(vertices.begin(), vertices.end()); - // Print some information about the polygon and coordinate functions. + // Print some information about the polygon and coordinates. wachspress_coordinates.print_information(); // Compute Wachspress coordinates for all the randomly defined points. diff --git a/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Discrete_harmonic_2.h b/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Discrete_harmonic_2.h index a25093f6b5c..e3232b132f2 100644 --- a/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Discrete_harmonic_2.h +++ b/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Discrete_harmonic_2.h @@ -55,8 +55,6 @@ namespace Barycentric_coordinates { \cgalModels `BarycentricCoordinates_2` \pre The provided polygon is strictly convex. - -\attention Weight functions (coordinates without normalization) are allowed to be computed for an arbitrary polygon. */ diff --git a/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Generalized_barycentric_coordinates_2.h b/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Generalized_barycentric_coordinates_2.h index 6a3e24ce554..f3726d04ca6 100644 --- a/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Generalized_barycentric_coordinates_2.h +++ b/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Generalized_barycentric_coordinates_2.h @@ -44,7 +44,7 @@ namespace Barycentric_coordinates { /*! * \ingroup PkgBarycentric_coordinates_2 - * The class `Generalized_barycentric_coordinates_2` implements the behaviour of generalized barycentric coordinates along the polygon's boundary and provides a common interface for all coordinate classes. + * The class `Generalized_barycentric_coordinates_2` implements generalized barycentric coordinates along the polygon's boundary and provides a common interface for all coordinate classes. * This class is parameterized by a coordinate class `Coordinate_2`, and a traits class `Traits`. \tparam Coordinate_2 must be a model of the concept `BarycentricCoordinates_2`. @@ -81,7 +81,7 @@ public: /// \name Creation /// @{ - /// Creates the class `Generalized_barycentric_coordinates_2` that implements the behaviour of generalized barycentric coordinates along the polygon's boundary given by a range of vertices `[first_vertex, last_vertex)`. + /// Creates the class `Generalized_barycentric_coordinates_2` that implements generalized barycentric coordinates along the polygon's boundary given by a range of vertices `[first_vertex, last_vertex)`. /// `InputIterator` must be an input iterator with a value type equivalent to `Traits::Point_2`. /// \pre Number of the polygon's vertices > 2. /// \pre The provided polygon is simple. diff --git a/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Mean_value_2.h b/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Mean_value_2.h index 244f8dd5cca..10567b72e51 100644 --- a/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Mean_value_2.h +++ b/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Mean_value_2.h @@ -28,11 +28,13 @@ #include // CGAL headers. +#include #include -#include +#include // Boost headers. #include +#include // CGAL namespace. namespace CGAL { @@ -309,23 +311,24 @@ private: // Following section 4.2 from [2] we denote P_j = r_j*r_{j+1} + dot_product(d_j, d_{j+1}). // Vector s_i from [1] corresponds to that one with the name d_i in [2]. - for(int j = 0; j < n-1; ++j) P[j] = r[j]*r[j+1] + s[j]*s[j+1]; - P[n-1] = r[n-1]*r[0] + s[n-1]*s[0]; + for(int j = 0; j < n-1; ++j) + P[j] = CGAL::max(r[j]*r[j+1] + scalar_product_2(s[j], s[j+1]), FT(0)); + P[n-1] = CGAL::max(r[n-1]*r[0] + scalar_product_2(s[n-1], s[0]), FT(0)); // Compute mean value weights using the formula (16) from [2]. // Since the formula (16) always gives positive values, we have to add a proper sign to all the weight functions. - weight[0] = r[n-1]*r[1] - s[n-1]*s[1]; + weight[0] = r[n-1]*r[1] - scalar_product_2(s[n-1], s[1]); for(int j = 1; j < n-1; ++j) weight[0] *= P[j]; weight[0] = sign_of_weight(A[n-1], A[0], B[0])*sqrt(weight[0]); for(int i = 1; i < n-1; ++i) { - weight[i] = r[i-1]*r[i+1] - s[i-1]*s[i+1]; + weight[i] = r[i-1]*r[i+1] - scalar_product_2(s[i-1], s[i+1]); for(int j = 0; j < i-1; ++j) weight[i] *= P[j]; for(int j = i+1; j < n; ++j) weight[i] *= P[j]; weight[i] = sign_of_weight(A[i-1], A[i], B[i])*sqrt(weight[i]); } - weight[n-1] = r[n-2]*r[0] - s[n-2]*s[0]; + weight[n-1] = r[n-2]*r[0] - scalar_product_2(s[n-2], s[0]); for(int j = 0; j < n-2; ++j) weight[n-1] *= P[j]; weight[n-1] = sign_of_weight(A[n-2], A[n-1], B[n-1])*sqrt(weight[n-1]); diff --git a/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Segment_coordinates_2.h b/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Segment_coordinates_2.h index b6b4b5b5cf2..4b4f970c029 100644 --- a/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Segment_coordinates_2.h +++ b/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Segment_coordinates_2.h @@ -79,7 +79,7 @@ public: /// \name Creation /// @{ - /// Creates the class `Segment_coordinates_2` that implements the behaviour of segment coordinates with respect to an arbitrary non-degenerate segment along an arbitrary line in the plane. + /// Creates the class `Segment_coordinates_2` that implements segment coordinates with respect to an arbitrary non-degenerate segment along an arbitrary line in the plane. /// The segment is given by its two vertices. /// \pre Segment is not degenerate. Segment_coordinates_2(const Point_2 &first_vertex, const Point_2 &second_vertex, const Traits &b_traits = Traits()) : @@ -203,6 +203,7 @@ private: // Global functions /*! + \anchor seg_coord_global * \relates Segment_coordinates_2 * This is a global function that takes both vertices of a segment and computes segment coordinates at a given query point with respect to these vertices. diff --git a/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Triangle_coordinates_2.h b/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Triangle_coordinates_2.h index f093b9c8c61..9fe93dfe24b 100644 --- a/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Triangle_coordinates_2.h +++ b/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Triangle_coordinates_2.h @@ -81,7 +81,7 @@ public: /// \name Creation /// @{ - /// Creates the class `Triangle_coordinates_2` that implements the behaviour of triangle coordinates with respect to an arbitrary non-degenerate triangle in the plane. + /// Creates the class `Triangle_coordinates_2` that implements triangle coordinates with respect to an arbitrary non-degenerate triangle in the plane. /// The triangle is given by its three vertices. /// \pre Triangle is not degenerate. Triangle_coordinates_2(const Point_2 &first_vertex, const Point_2 &second_vertex, const Point_2 &third_vertex, const Traits &b_traits = Traits()) : diff --git a/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Wachspress_2.h b/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Wachspress_2.h index b381e8ee035..154595b2b24 100644 --- a/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Wachspress_2.h +++ b/Barycentric_coordinates_2/include/CGAL/Barycentric_coordinates_2/Wachspress_2.h @@ -54,9 +54,7 @@ namespace Barycentric_coordinates { \cgalModels `BarycentricCoordinates_2` -\pre The provided polygon is strictly convex. - -\attention Weight functions (coordinates without normalization) are allowed to be computed for an arbitrary polygon. +\pre The provided polygon is strictly convex. */ diff --git a/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/copyright b/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/copyright index 379ab1600ab..ad96e5727c9 100644 --- a/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/copyright +++ b/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/copyright @@ -1 +1 @@ -Università della Svizzera italiana (Switzerland) and INRIA Sophia-Antipolis (France). +Università della Svizzera italiana (Switzerland) and INRIA Sophia-Antipolis (France) diff --git a/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/description.txt b/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/description.txt index 6241980d131..ab0d977ebf0 100644 --- a/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/description.txt +++ b/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/description.txt @@ -1 +1 @@ -2D Generalized Barycentric Coordinates for simple polygons. +2D Generalized Barycentric Coordinates for simple polygons diff --git a/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/license.txt b/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/license.txt index 47acd0824c4..8bb8efcb72b 100644 --- a/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/license.txt +++ b/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/license.txt @@ -1 +1 @@ -GPL (v3 or later). +GPL (v3 or later) diff --git a/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/long_description.txt b/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/long_description.txt index f9542364b08..4e4413d731d 100644 --- a/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/long_description.txt +++ b/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/long_description.txt @@ -1 +1 @@ -The package "2D Generalized Barycentric Coordinates" offers an efficient and robust implementation of two-dimensional closed-form generalized barycentric coordinates defined for simple two-dimensional polygons. If coordinates with respect to multivariate scattered points instead of a polygon are required, please refer to natural neighbour coordinates from the package \ref chapinterpolation "2D and Surface Function Interpolation". +The package 2D Generalized Barycentric Coordinates offers an efficient and robust implementation of two-dimensional closed-form generalized barycentric coordinates defined for simple two-dimensional polygons. If coordinates with respect to multivariate scattered points instead of a polygon are required, please refer to natural neighbour coordinates from the package 2D and Surface Function Interpolation. diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_speed_test.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_speed_test.cpp index 57b0019877c..87b3a06fe5b 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_speed_test.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_speed_test.cpp @@ -72,4 +72,4 @@ int main() cout << endl << "CPU time to compute Discrete Harmonic coordinates (4 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_speed_test_100_vertices.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_speed_test_100_vertices.cpp index 71a78ea312f..d56221fc861 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_speed_test_100_vertices.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_speed_test_100_vertices.cpp @@ -87,4 +87,4 @@ int main() cout << endl << "CPU time to compute Discrete Harmonic coordinates (100 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_speed_test_with_many_vertices.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_speed_test_with_many_vertices.cpp index 03aadcb57fe..e5a3c5d25df 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_speed_test_with_many_vertices.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_speed_test_with_many_vertices.cpp @@ -84,4 +84,4 @@ int main() cout << endl << "CPU time to compute Discrete Harmonic coordinates (16 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_weights_speed_test.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_weights_speed_test.cpp index c25ce976d9d..1776ed66bb2 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_weights_speed_test.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_weights_speed_test.cpp @@ -72,4 +72,4 @@ int main() cout << endl << "CPU time to compute Discrete Harmonic weights (4 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_weights_speed_test_with_many_vertices.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_weights_speed_test_with_many_vertices.cpp index 564463303c1..f025e2d8876 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_weights_speed_test_with_many_vertices.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Discrete_harmonic_coordinates/DH_weights_speed_test_with_many_vertices.cpp @@ -84,4 +84,4 @@ int main() cout << endl << "CPU time to compute Discrete Harmonic weights (16 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test.cpp index 5b5a52d4230..d67e6aaf1a7 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test.cpp @@ -72,4 +72,4 @@ int main() cout << endl << "CPU time to compute Mean Value coordinates (4 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test_100_vertices.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test_100_vertices.cpp index 8799868b648..8010aabb9b8 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test_100_vertices.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test_100_vertices.cpp @@ -87,4 +87,4 @@ int main() cout << endl << "CPU time to compute Mean Value coordinates (100 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test_with_34_vertices.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test_with_34_vertices.cpp index b6513a40df2..ddf6c8d41ef 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test_with_34_vertices.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test_with_34_vertices.cpp @@ -102,4 +102,4 @@ int main() cout << endl << "CPU time to compute Mean Value coordinates (34 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test_with_many_vertices.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test_with_many_vertices.cpp index 0466f542181..4fc22023de3 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test_with_many_vertices.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_speed_test_with_many_vertices.cpp @@ -84,4 +84,4 @@ int main() cout << endl << "CPU time to compute Mean Value coordinates (16 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_weights_speed_test.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_weights_speed_test.cpp index 6e1b2e2f470..e28aae57070 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_weights_speed_test.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_weights_speed_test.cpp @@ -72,4 +72,4 @@ int main() cout << endl << "CPU time to compute Mean Value weights (4 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_weights_speed_test_with_34_vertices.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_weights_speed_test_with_34_vertices.cpp index c04d31b0754..687ebce3ff3 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_weights_speed_test_with_34_vertices.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_weights_speed_test_with_34_vertices.cpp @@ -102,4 +102,4 @@ int main() cout << endl << "CPU time to compute Mean Value weights (34 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_weights_speed_test_with_many_vertices.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_weights_speed_test_with_many_vertices.cpp index e52e9f70d9c..a9e929ded64 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_weights_speed_test_with_many_vertices.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Mean_value_coordinates/MV_weights_speed_test_with_many_vertices.cpp @@ -84,4 +84,4 @@ int main() cout << endl << "CPU time to compute Mean Value weights (16 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Segment_coordinates/Segment_coordinates_speed_test.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Segment_coordinates/Segment_coordinates_speed_test.cpp index f4fc59e6a75..3632527cecb 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Segment_coordinates/Segment_coordinates_speed_test.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Segment_coordinates/Segment_coordinates_speed_test.cpp @@ -63,4 +63,4 @@ int main() cout << endl << "CPU time to compute Segment coordinates = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Triangle_coordinates/Triangle_coordinates_speed_test.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Triangle_coordinates/Triangle_coordinates_speed_test.cpp index c129a363934..20c56f2e313 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Triangle_coordinates/Triangle_coordinates_speed_test.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Triangle_coordinates/Triangle_coordinates_speed_test.cpp @@ -65,4 +65,4 @@ int main() cout << endl << "CPU time to compute Triangle coordinates = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_speed_test.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_speed_test.cpp index 1e855091759..f29d79f7768 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_speed_test.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_speed_test.cpp @@ -72,4 +72,4 @@ int main() cout << endl << "CPU time to compute Wachspress coordinates (4 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_speed_test_100_vertices.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_speed_test_100_vertices.cpp index 01a0d1b7801..d993555ea3e 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_speed_test_100_vertices.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_speed_test_100_vertices.cpp @@ -87,4 +87,4 @@ int main() cout << endl << "CPU time to compute Wachspress coordinates (100 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_speed_test_with_many_vertices.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_speed_test_with_many_vertices.cpp index 8410b0614a8..3220a902415 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_speed_test_with_many_vertices.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_speed_test_with_many_vertices.cpp @@ -84,4 +84,4 @@ int main() cout << endl << "CPU time to compute Wachspress coordinates (16 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_weights_speed_test.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_weights_speed_test.cpp index 4f65ea1cafd..e75aea2ad0c 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_weights_speed_test.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_weights_speed_test.cpp @@ -72,4 +72,4 @@ int main() cout << endl << "CPU time to compute Wachspress weights (4 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_weights_speed_test_with_many_vertices.cpp b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_weights_speed_test_with_many_vertices.cpp index bddc9ff2a68..1883c7f08d0 100644 --- a/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_weights_speed_test_with_many_vertices.cpp +++ b/Barycentric_coordinates_2/speed_test/Barycentric_coordinates_2/Wachspress_coordinates/WP_weights_speed_test_with_many_vertices.cpp @@ -84,4 +84,4 @@ int main() cout << endl << "CPU time to compute Wachspress weights (16 vertices) = " << mean_time << " seconds." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Almost_degenerate_segment_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Almost_degenerate_segment_test.cpp index 288299d2542..dcf0211c687 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Almost_degenerate_segment_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Almost_degenerate_segment_test.cpp @@ -73,4 +73,4 @@ int main() cout << endl << "Almost_degenerate_segment_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Almost_degenerate_triangle_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Almost_degenerate_triangle_test.cpp index 9746d5a4ec2..846088cf393 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Almost_degenerate_triangle_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Almost_degenerate_triangle_test.cpp @@ -83,4 +83,4 @@ int main() cout << endl << "Almost_degenerate_triangle_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Computation_at_vertices_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Computation_at_vertices_test.cpp index df6d6a32aa4..a28570f9a29 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Computation_at_vertices_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Computation_at_vertices_test.cpp @@ -98,4 +98,4 @@ int main() cout << endl << "Computation_at_vertices_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Computation_on_boundary_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Computation_on_boundary_test.cpp index eb6cb9cae5e..a9f0f713e91 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Computation_on_boundary_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Computation_on_boundary_test.cpp @@ -165,4 +165,4 @@ int main() cout << endl << "Computation_on_boundary_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Computation_on_edges_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Computation_on_edges_test.cpp index 961f2a98bff..b55607623f5 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Computation_on_edges_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Computation_on_edges_test.cpp @@ -98,4 +98,4 @@ int main() cout << endl << "Computation_on_edges_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/DH_almost_degenerate_polygon_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/DH_almost_degenerate_polygon_test.cpp index 48302be9ad5..2fbcbf78da0 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/DH_almost_degenerate_polygon_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/DH_almost_degenerate_polygon_test.cpp @@ -122,4 +122,4 @@ int main() cout << endl << "DH_almost_degenerate_polygon_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/DH_const_linear_precision_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/DH_const_linear_precision_test.cpp index f73ff849f9a..125bae691b1 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/DH_const_linear_precision_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/DH_const_linear_precision_test.cpp @@ -92,4 +92,4 @@ int main() cout << endl << "DH_const_linear_precision_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/DH_triangle_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/DH_triangle_test.cpp index c1254a28136..c514b6664cf 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/DH_triangle_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/DH_triangle_test.cpp @@ -72,4 +72,4 @@ int main() cout << endl << "DH_triangle_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/DH_weights_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/DH_weights_test.cpp index 20d5f480dda..f797371f1b9 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/DH_weights_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/DH_weights_test.cpp @@ -112,4 +112,4 @@ int main() cout << endl << "DH_weights_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_const_linear_precision_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_const_linear_precision_test.cpp index c691dfa44da..e694ac1b698 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_const_linear_precision_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_const_linear_precision_test.cpp @@ -111,4 +111,4 @@ int main() cout << endl << "MV_const_linear_precision_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_special_points_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_special_points_test.cpp index cff9b7ca3b9..f8af1f332fb 100755 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_special_points_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_special_points_test.cpp @@ -122,4 +122,4 @@ int main() cout << endl << "MV_special_points_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_triangle_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_triangle_test.cpp index 5808e746aa8..46898c20531 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_triangle_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_triangle_test.cpp @@ -73,4 +73,4 @@ int main() cout << endl << "MV_triangle_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_weakly_convex_polygon_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_weakly_convex_polygon_test.cpp index f804396d7b5..593f26e7952 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_weakly_convex_polygon_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_weakly_convex_polygon_test.cpp @@ -83,4 +83,4 @@ int main() cout << endl << "MV_weakly_convex_polygon_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_weights_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_weights_test.cpp index 94d2ee5f7bd..d3c0304f707 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_weights_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/MV_weights_test.cpp @@ -83,4 +83,4 @@ int main() cout << endl << "MV_weights_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Segment_coordinates_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Segment_coordinates_test.cpp index a8f414f878b..5f033d2ea95 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Segment_coordinates_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Segment_coordinates_test.cpp @@ -80,4 +80,4 @@ int main() cout << endl << "Segment_coordinates_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Segment_coordinates_with_offset_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Segment_coordinates_with_offset_test.cpp index 121ee246e1d..4da5e9d36ea 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Segment_coordinates_with_offset_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Segment_coordinates_with_offset_test.cpp @@ -80,4 +80,4 @@ int main() cout << endl << "Segment_coordinates_with_offset_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Segment_test_with_point_2.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Segment_test_with_point_2.cpp index 57fe9903ade..5c7bdae3d09 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Segment_test_with_point_2.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Segment_test_with_point_2.cpp @@ -40,4 +40,4 @@ int main() cout << endl << "Segment_test_with_point_2: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Triangle_coordinates_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Triangle_coordinates_test.cpp index 7ad79c5b1da..c2c4d1b27cc 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Triangle_coordinates_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Triangle_coordinates_test.cpp @@ -80,4 +80,4 @@ int main() cout << endl << "Triangle_coordinates_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Triangle_test_with_point_3.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Triangle_test_with_point_3.cpp index 45a42869a49..cc690417a55 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Triangle_test_with_point_3.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/Triangle_test_with_point_3.cpp @@ -42,4 +42,4 @@ int main() cout << endl << "Triangle_test_with_point_3: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_DH_unit_square_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_DH_unit_square_test.cpp index 90fd08c22ac..05d15364f14 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_DH_unit_square_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_DH_unit_square_test.cpp @@ -69,4 +69,4 @@ int main() cout << endl << "WP_DH_unit_square_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_almost_degenerate_polygon_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_almost_degenerate_polygon_test.cpp index ba831c9ca70..5f039a2e492 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_almost_degenerate_polygon_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_almost_degenerate_polygon_test.cpp @@ -123,4 +123,4 @@ int main() cout << endl << "WP_almost_degenerate_polygon_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_const_linear_precision_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_const_linear_precision_test.cpp index 33131ac9951..132963a7937 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_const_linear_precision_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_const_linear_precision_test.cpp @@ -92,4 +92,4 @@ int main() cout << endl << "WP_const_linear_precision_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_triangle_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_triangle_test.cpp index 7a25296fc37..41a3112803e 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_triangle_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_triangle_test.cpp @@ -72,4 +72,4 @@ int main() cout << endl << "WP_triangle_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_weights_test.cpp b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_weights_test.cpp index fc91fcbb78b..59af090120f 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_weights_test.cpp +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/WP_weights_test.cpp @@ -112,4 +112,4 @@ int main() cout << endl << "WP_weights_test: PASSED." << endl << endl; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/Barycentric_coordinates_2/todo.txt b/Barycentric_coordinates_2/todo.txt index 4ffb68d1472..4a3d109b7fc 100755 --- a/Barycentric_coordinates_2/todo.txt +++ b/Barycentric_coordinates_2/todo.txt @@ -1,3 +1,5 @@ 1. To make the code parallel. Get iteration number from the thread. Add parallel class to each type of the coordinate functions. Use begin() + offset. Resize vector. Parallel class takes as parameters list of points and polygon. Use random access iterator. - Done but we have problems with it. -2. Add hard tests with epsilon distance away from the polygon’s boundary, which we have discussed during our first group meeting, to current test suit. \ No newline at end of file +2. Add hard tests with epsilon distance away from the polygon’s boundary, which we have discussed during our first group meeting, to current test suit. + +3. Debug the last example. Fix the bug with Projection_traits_xy. \ No newline at end of file