The truth is rarely pure and never simple

qhull minimal example

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.

#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;
}

Leave a Reply to Shekar Mantha Cancel reply

Your email address will not be published.

7 thoughts on “qhull minimal example”