File: linear_interpolation_of_vector_3.cpp

package info (click to toggle)
cgal 6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144,912 kB
  • sloc: cpp: 810,858; ansic: 208,477; sh: 493; python: 411; makefile: 286; javascript: 174
file content (43 lines) | stat: -rw-r--r-- 1,484 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#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::Vector_3                                         Vector_3;
typedef K::Point_2                                          Point_2;

int main()
{
  Delaunay_triangulation T;

  typedef std::map<Point_2, Vector_3, K::Less_xy_2>           Coord_map;
  typedef CGAL::Data_access<Coord_map>                      Value_access;

  Coord_map value_function;

  for (int y=0 ; y<255 ; y++){
    for (int x=0 ; x<255 ; x++){
      K::Point_2 p(x,y);
      T.insert(p);
      value_function.insert(std::make_pair(p, Vector_3(x,y,1)));
    }
  }

  //coordinate computation
  K::Point_2 p(1.3, 0.34);
  std::vector<std::pair<Point_2, double> > coords;

  double norm = CGAL::natural_neighbor_coordinates_2(T, p, std::back_inserter(coords)).second;
  Vector_3 res =  CGAL::linear_interpolation(coords.begin(), coords.end(), norm,
                                           Value_access(value_function));

  std::cout << "Tested interpolation on " << p << " interpolation: "
            << res << std::endl;

  return EXIT_SUCCESS;
}