【发布时间】:2015-10-07 04:33:31
【问题描述】:
我使用 CGAL 库创建了一个带有一些 3D 点的凸包。现在我想检查一个点是否在船体内部。但找不到任何选择这样做。有人可以帮忙吗?
我的代码如下。
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/point_generators_3.h>
#include <CGAL/algorithm.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/convex_hull_3.h>
#include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef K::Point_3 Point;
std::vector<Point> hullPoints[16];
int numPoints[16];
Polyhedron poly[16];
//Reading hull points
for(int i=0;i<a->vertI;i++)
{
for(int j=0;j<16;j++)
{
if(a->vertices[i][1] <= (a->maxY-(j*(a->maxY-a->minY)/16.0)) && a->vertices[i][1] >= (a->maxY-((j+1)*(a->maxY-a->minY)/16.0)) )
{
hullPoints[j].push_back(Point(a->vertices[i][0],a->vertices[i][1],a->vertices[i][2]));
}
}
}
//Create hull
for(int i=0;i<16;i++)
{
CGAL::convex_hull_3(hullPoints[i].begin(), hullPoints[i].end(), poly[i]);
std::cout << "The convex hull " << i <<" contains " << poly[i].size_of_vertices() << " vertices" << std::endl;
}
它完美地工作,我可以访问 Poly 以查看其中不存在任何顶点。但无法找到并检查某个点是否在其中。
【问题讨论】:
标签: collision-detection cgal convex-hull