获取点周围的面片——基于CGAL 三角剖分
CGAL(计算几何算法库)提供了各种算法来处理几何问题。其中,三角剖分算法是其中一个常用的算法之一。在CGAL中,我们可以通过实例化Triangulation_2类来进行二维三角剖分。本文将介绍如何在Triangulation_2中获取某一端点周围的面片。
首先,我们需要创建一个Triangulation_2对象并插入一些点。这里我们创建了一个正方形边界,并以圆形定位符号为中心插入了一些随机点。
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Triangulation;
typedef K::Point_2 Point;
int main() {
Triangulation T;
T.insert(Point(0,0));
T.insert(Point(1,0));
T.insert(Point(1,1));
T.insert(Point(0,1));
// Inserting some random points
for(int i = 0; i < 10; i++) {
double x = (double)std::rand()/RAND_MAX
本文介绍了如何利用CGAL的三角剖分算法获取二维平面上特定点周围的面片。通过创建Triangulation_2对象,插入点,然后使用特定函数获取指定点p的相邻面片。代码示例展示了这一过程。
订阅专栏 解锁全文
1403

被折叠的 条评论
为什么被折叠?



