Drake
convexHull.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 #include <Eigen/Dense>
5 #include "drake/drakeConvexHull_export.h"
6 
7 typedef double coord_t; // coordinate type
8 typedef double coord2_t; // must be big enough to hold 2*max(|coordinate|)^2
9 
10 struct DRAKECONVEXHULL_EXPORT Point {
12 
13  bool operator<(const Point &p) const {
14  return x < p.x || (x == p.x && y < p.y);
15  }
16 };
17 
18 DRAKECONVEXHULL_EXPORT std::vector<Point> convexHull(std::vector<Point> P);
19 DRAKECONVEXHULL_EXPORT bool inConvexHull(
20  const Eigen::Ref<const Eigen::Matrix<double, 2, Eigen::Dynamic>> &P,
21  const Eigen::Ref<const Eigen::Vector2d> &q, double tolerance = 1e-16);
22 
23 // Returns the perpendicular distance from point q to the convex hull of pts.
24 // Specifically, if pts form a polytope defined by a_i'x <= b_i where each a_i
25 // is a unit vector, then this returns:
26 //
27 // d* = min [b_i - a_i'q]
28 // i
29 //
30 // If q is inside the convex hull of pts, then d* will be positive, else it will
31 // be negative.
32 DRAKECONVEXHULL_EXPORT double signedDistanceInsideConvexHull(
33  const Eigen::Ref<const Eigen::Matrix<double, 2, Eigen::Dynamic>> &pts,
34  const Eigen::Ref<const Eigen::Vector2d> &q);
DRAKECONVEXHULL_EXPORT std::vector< Point > convexHull(std::vector< Point > P)
Definition: convexHull.cpp:25
std::vector< Number > x
Definition: IpoptSolver.cpp:169
bool operator<(const Point &p) const
Definition: convexHull.h:13
Definition: convexHull.h:10
coord_t x
Definition: convexHull.h:11
double coord_t
Definition: convexHull.h:7
DRAKECONVEXHULL_EXPORT bool inConvexHull(const Eigen::Ref< const Eigen::Matrix< double, 2, Eigen::Dynamic >> &P, const Eigen::Ref< const Eigen::Vector2d > &q, double tolerance=1e-16)
double coord2_t
Definition: convexHull.h:8
DRAKECONVEXHULL_EXPORT double signedDistanceInsideConvexHull(const Eigen::Ref< const Eigen::Matrix< double, 2, Eigen::Dynamic >> &pts, const Eigen::Ref< const Eigen::Vector2d > &q)
coord_t y
Definition: convexHull.h:11