首页 > 其他 > 详细

Easiest way to use Qhull library in your code.

时间:2015-07-14 20:07:04      阅读:380      评论:0      收藏:0      [点我收藏+]

The qhull library has a central point with a few samples to start from when you want to use it in your code. Most interestingly, the developers invite you to call the qconvex program as an external application in case you want to calculate the convex hull of a point set. This may be the easy way for a few calls but will lead to resource wasting in case you want to do many calls. Of course, the developers tell you to use the C++ interface instead of the C interface. But on the same page, they tell you to be careful with the C++ bindings, as they are new and experimental. In case you are as confused as I am, here is the shortest way I know of to get the area and volume of a convex hull.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
extern "C" {
    #include <qhull/qhull_a.h>
}
 
using namespace std;
 
int main(void) {
    int numpoints = 4;
    coordT points[] = {0,0,0, 1,0,0, 0,1,0, 0,0,1};
    int dim = 3;
    char flags[25];
    sprintf (flags, "qhull s FA");
 
    qh_new_qhull(dim, numpoints, points, 0, flags, NULL, NULL);
    qh_getarea(qh facet_list);
    cout << qh totvol << endl;
    cout << qh totarea << endl;
    qh_freeqhull(!qh_ALL);
 
    return 0;
}

 

Original article url: http://guido.vonrudorff.de/qhull-minimal-example/

Easiest way to use Qhull library in your code.

原文:http://www.cnblogs.com/jast/p/4646372.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!