se2ez
geometry.cpp
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
3 #include <iostream>
4 
5 #include <se2ez/core.h>
6 
7 using namespace se2ez;
8 
9 int main(int /*argc*/, char ** /*argv*/)
10 {
11  // tf::EigenVector<Eigen::Vector2d> points = {
12  // {0.0, 0.0}, {0.5, 0.0}, {1.0, 0.0}, {1.5, 0.0}, {2.0, 0.0}, {2.0, 0.5}, {2.0, 1.0}, {2.0, 1.5},
13  // {2.0, 2.0}, {1.5, 2.0}, {1.0, 2.0}, {0.5, 2.0}, {0.0, 2.0}, {0.0, 1.5}, {0.0, 1.0}, {0.0, 0.5},
14  // };
15 
17  {391, 374}, {240, 431}, {252, 340}, {374, 320}, {289, 214}, {134, 390}, {68, 186},
18  {154, 259}, {161, 107}, {435, 108}, {208, 148}, {295, 160}, {421, 212}, {441, 303},
19  };
20 
21  auto geometry = std::make_shared<Geometry>(Geometry::SIMPLE, points, Eigen::Vector3d{0, 0, 0});
22  std::cout << "Original:" << std::endl;
23  std::cout << geometry->printGeometry() << std::endl;
25 
26  auto partitions = geo::convexifyOptimal(geometry);
27  for (const auto &convex : partitions)
28  {
29  std::cout << "Convex Partition:" << std::endl;
30  std::cout << convex->printGeometry() << std::endl;
32 
33  auto triangles = geo::shatter(convex);
34  std::cout << "Shattered:" << std::endl;
35  for (const auto &tri : triangles)
36  std::cout << tri->printGeometry() << std::endl;
38  }
39 
40  return 0;
41 }
std::vector< GeometryPtr > shatter(const GeometryPtr &geometry)
"Shatters" a convex polygon into a fan of triangles using the first point as the root for all triangl...
Definition: polygon.cpp:167
T endl(T... args)
A simple polygon (no holes).
Definition: geometry.h:36
std::vector< GeometryPtr > convexifyOptimal(const GeometryPtr &geometry)
Performs an optimal convex decomposition on the geometry.
Definition: polygon.cpp:141
Main namespace.
Definition: collision.h:11
int main(int, char **)
Definition: geometry.cpp:9