File: convergence.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 (37 lines) | stat: -rw-r--r-- 1,132 bytes parent folder | download | duplicates (2)
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
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Weights/three_point_family_weights.h>

// Typedefs.
using Kernel  = CGAL::Simple_cartesian<double>;
using FT      = typename Kernel::FT;
using Point_2 = typename Kernel::Point_2;

int main() {
  std::cout << std::fixed;

  // 3D configuration.
  const Point_2 p0(0, 1);
  const Point_2 p1(2, 0);
  const Point_2 p2(7, 1);
  const Point_2 q0(3, 1);

  // Choose a type of the weight:
  // e.g. 0 - Wachspress (WP) weight; 1 - mean value (MV);
  const FT wp = 0.0;
  const FT mv = 1.0;

  // Compute WP and MV weights.
  std::cout << "3D Wachspress (WP, q0): ";
  std::cout << CGAL::Weights::three_point_family_weight(p0, p1, p2, q0, wp) << std::endl;
  std::cout << "3D mean value (MV, q0): ";
  std::cout << CGAL::Weights::three_point_family_weight(p0, p1, p2, q0, mv) << std::endl;

  // Converge WP towards MV.
  std::cout << "Converge WP to MV on q0: " << std::endl;
  const FT step = 0.1;
  for (FT x = 0.0; x <= 1.0; x += step) {
    std::cout << "3D x: ";
    std::cout << CGAL::Weights::three_point_family_weight(p0, p1, p2, q0, x) << std::endl;
  }
  return EXIT_SUCCESS;
}