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/

  • 相关阅读:
    服务返返回状态码详解
    LeetCode#28 Implement strStr()
    LeetCode#58 Length of Last Word
    LeetCode#66 Plus One
    spooling技术
    文件的打开与关闭
    DMA方式与通道方式
    中断向量、向量中断、向量地址
    中断响应优先级和中断处理优先级
    I/O接口
  • 原文地址:https://www.cnblogs.com/jast/p/4646372.html
Copyright © 2011-2022 走看看