File: se2_DeCasteljau.cpp

package info (click to toggle)
manif 0.0.5-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,576 kB
  • sloc: cpp: 11,789; ansic: 8,774; python: 2,158; sh: 24; makefile: 23; xml: 21
file content (44 lines) | stat: -rw-r--r-- 1,173 bytes parent folder | download
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
44
#include "se2_points_generator.h"
#include "manif/algorithms/decasteljau.h"

#include <iostream>

/**
 * @brief An example of the use of the decasteljau algorithm.
 */

int main(int argc, char** argv)
{
  if (argc < 4)
  {
    std::cout << "Usage: .se2_decateljau <k> <d> <p>\n";
    std::cout << "\t with k: number of initial points on the 8-shaped curve.\n";
    std::cout << "\t with d: degree of smoothness of the generated curve.\n";
    std::cout << "\t with p: number of points to generate between consecutive points of the initial curve.\n";
    return EXIT_SUCCESS;
  }

  int k, d, p;

  k = atoi(argv[1]);
  d = atoi(argv[2]);
  p = atoi(argv[3]);

  const auto points = manif::generateSE2PointsOnHeightShape(k);

  std::cout << "Initial points:\n";
  for (const auto& point : points)
    std::cout << point.x() << ","
              << point.y() << ","
              << point.angle() << "\n";

  std::cout << "Generated points:\n";
  const auto curve = manif::decasteljau(points, d, p, true);

  for (const auto& point : curve)
    std::cout << point.x() << ","
              << point.y() << ","
              << point.angle() << "\n";

  return EXIT_SUCCESS;
}