Easiest way to use Qhull library in your code.

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/

原文链接: https://www.cnblogs.com/jast/p/4646372.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    Easiest way to use Qhull library in your code.

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/219117

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月13日 上午10:26
下一篇 2023年2月13日 上午10:26

相关推荐