zoukankan      html  css  js  c++  java
  • 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/

  • 相关阅读:
    ZOJ 2588 Burning Bridges
    POJ 1966 ZOJ 2182 Cable TV Network
    HDU 5348 MZL's endless loop
    HDU 5352 MZL's City
    Tarjan算法求解无向连通图的割点、割边、点双连通分量和边双连通分量的模板
    ZOJ 1119 SPF
    HDU 3452 Bonsai
    HDU 1520 Anniversary party
    POJ 2239 Selecting Courses
    POJ 1144 Network
  • 原文地址:https://www.cnblogs.com/jast/p/4646372.html
Copyright © 2011-2022 走看看