CGAL 6.1.2 - 2D and Surface Function Interpolation: Interpolation/linear_interpolation_2.cpp

CGAL 6.1.2 - 2D and Surface Function Interpolation

Loading...
Searching...
No Matches
Interpolation/linear_interpolation_2.cpp
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Interpolation_traits_2.h>
#include <CGAL/natural_neighbor_coordinates_2.h>
#include <CGAL/interpolation_functions.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Delaunay_triangulation;
typedef CGAL::Interpolation_traits_2<K> Traits;
typedef K::FT Coord_type;
typedef K::Point_2 Point;
int main()
{
Delaunay_triangulation T;
typedef std::map<Point, Coord_type, K::Less_xy_2> Coord_map;
typedef CGAL::Data_access<Coord_map> Value_access;
Coord_map value_function;
Coord_type a(0.25), bx(1.3), by(-0.7);
for (int y=0 ; y<3 ; y++){
for (int x=0 ; x<3 ; x++){
K::Point_2 p(x,y);
T.insert(p);
value_function.insert(std::make_pair(p, a + bx*x + by*y));
}
}
//coordinate computation
K::Point_2 p(1.3, 0.34);
std::vector<std::pair<Point, Coord_type> > coords;
Coord_type norm = CGAL::natural_neighbor_coordinates_2(T, p, std::back_inserter(coords)).second;
Coord_type res = CGAL::linear_interpolation(coords.begin(), coords.end(), norm,
Value_access(value_function));
std::cout << "Tested interpolation on " << p << " interpolation: "
<< res << " exact: " << a + bx*p.x() + by*p.y() << std::endl;
return EXIT_SUCCESS;
}
CGAL::Delaunay_triangulation_2
CGAL::Exact_predicates_inexact_constructions_kernel
CGAL::Interpolation_traits_2
Interpolation_traits_2 is a model for the concept InterpolationTraits and can be used to instantiate ...
Definition: Interpolation_traits_2.h:22
CGAL::linear_interpolation
ValueFunctor::result_type::first_type linear_interpolation(CoordinateInputIterator first, CoordinateInputIterator beyond, const typename std::iterator_traits< CoordinateInputIterator >::value_type::second_type &norm, ValueFunctor value_function)
The function linear_interpolation() computes the weighted sum of the function values which must be pr...
CGAL::natural_neighbor_coordinates_2
CGAL::Triple< CoordinateOutputIterator, typename Dt::Geom_traits::FT, bool > natural_neighbor_coordinates_2(const Dt &dt, const typename Dt::Geom_traits::Point_2 &p, CoordinateOutputIterator out, OutputFunctor fct, typename Dt::Face_handle start=typename Dt::Face_handle())
Computes the natural neighbor coordinates for p with respect to the points in the two-dimensional Del...
CGAL::Data_access
The struct Data_access implements a functor that allows to retrieve data from an associative containe...
Definition: interpolation_functions.h:26