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-to-call the Qconvex program as a external application in case you want to C Alculate the convex hull of a point set. This is the easy-to-be-few-a-calls but would-be-lead-to-resource wasting in-case-you-want-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 is careful with the C + + bindings, as they is new and experimental. As confused as I am, here is the shortest-I know of the area and volume of a convex hull.
12345678910111213141516171819202122 |
#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 the Qhull library in your code.