75 printf(
"\n%d vertices and %d facets with normals:\n",
79 printf(
"%6.2g ", facet->
normal[k]);
92 for (j=0; j<numpoints; j++) {
93 point= points + j*dim;
122 for (j= 0; j < numnew ; j++) {
123 point= points + (numpoints+j)*dim;
132 point[k]= (j & 1) ? 2.0 : -2.0;
141 printf(
"%d vertices and %d facets\n",
159 seed= (int)time(NULL);
160 printf(
"seed: %d\n", seed);
162 for (j=0; j<numpoints; j++) {
163 point= points + j*dim;
164 for (k= 0; k < dim-1; k++) {
189 for (j= 0; j < numnew ; j++) {
190 point= points + (numpoints+j)*dim;
197 for (k= 0; k < dim-1; k++) {
208 printf(
"%d points, %d extra points, %d vertices, and %d facets in total\n",
237 for (k= 0; k < dim-1; k++)
242 fprintf(stderr,
"findDelaunay: not implemented for triangulated, non-simplicial Delaunay regions (tricoplanar facet, f%d).\n",
247 for (k=0; k < dim-1; k++)
248 printf(
"%5.2f ", vertex->
point[k]);
263 for (j=0; j<numpoints; j++) {
264 point= points + j*(dim+1);
298 coordT *point, normal[100], offset, *next;
303 for (j= 0; j < numnew ; j++) {
307 normal[k]= sqrt((
coordT)dim);
309 normal[k]= -normal[k];
313 point= points + (numpoints+j)* (dim+1);
320 qh_printpoint(qh, stdout,
"added offset -1 and normal", normal);
321 printf(
"%d points, %d extra points, %d vertices, and %d facets in total\n",
333 #define SIZEcube (1<<DIM) 334 #define SIZEdiamond (2*DIM) 335 #define TOTpoints (SIZEcube + SIZEdiamond) 346 int main(
int argc,
char *argv[]) {
348 int curlong, totlong, exitcode;
355 printf(
"This is the output from user_eg2_r.c\n\n\ 356 It shows how qhull() may be called from an application using qhull's\n\ 357 static, reentrant library. user_eg2 is not part of qhull itself. If it\n\ 358 appears accidently, please remove user_eg2_r.c from your project. If it fails\n\ 359 immediately, user_eg2_r.c was incorrectly linked to the non-reentrant library.\n\ 360 Also try 'user_eg2 T1 2>&1'\n\n");
366 qh_init_A(qh, stdin, stdout, stderr, 0, NULL);
373 sprintf(options,
"qhull s Tcv Q11 %s ", argc >= 2 ? argv[1] :
"");
375 printf(
"\ncompute triangulated convex hull of cube after rotating input\n");
384 printf(
"\nadd points in a diamond\n");
395 if (curlong || totlong)
396 fprintf(stderr,
"qhull warning (user_eg2, run 1): did not free %d bytes of long memory (%d pieces)\n",
401 qh_init_A(qh, stdin, stdout, stderr, 0, NULL);
408 sprintf(options,
"qhull s d Tcv %s", argc >= 3 ? argv[2] :
"");
410 printf(
"\ncompute %d-d Delaunay triangulation\n",
DIM-1);
427 printf(
"\nadd points to triangulation\n");
433 printf(
"\nfind Delaunay triangle closest to [0.5, 0.5, ...]\n");
439 if (curlong || totlong)
440 fprintf(stderr,
"qhull warning (user_eg2, run 2): did not free %d bytes of long memory (%d pieces)\n",
445 qh_init_A(qh, stdin, stdout, stderr, 0, NULL);
453 sprintf(options,
"qhull H0 s Tcv %s", argc >= 4 ? argv[3] :
"");
455 printf(
"\ncompute halfspace intersection about the origin for a diamond\n");
467 printf(
"\nadd halfspaces for cube to intersection\n");
478 if (curlong || totlong)
479 fprintf(stderr,
"qhull warning (user_eg2, run 3): did not free %d bytes of long memory (%d pieces)\n",
496 fprintf(qh->
ferr,
"qhull error while processing previous error. Exit program\n");
505 fprintf(qh->
ferr,
"\nLast point added to hull was p%d", qh->
furthest_id);
509 fprintf(qh->
ferr,
"\nQhull has finished constructing the hull.");
511 fprintf(qh->
ferr,
"\nQhull has started post-merging");
512 fprintf(qh->
ferr,
"\n\n");
515 fprintf(qh->
ferr,
"qhull error while ending program. Exit program\n");
521 longjmp(qh->
errexit, exitcode);
531 fprintf(qh->
ferr,
"%s facets f%d f%d ridge r%d vertex v%d\n",
549 fprintf( qh->
ferr,
"facet f%d\n", facet->
id);
562 A Qhull error has occurred. Qhull should have corrected the above\n\ 563 precision error. Please send the input and all of the output to\n\ 564 qhull_bug@qhull.org\n");
567 Precision problems were detected during construction of the convex hull.\n\ 568 This occurs because convex hull algorithms assume that calculations are\n\ 569 exact, but floating-point arithmetic has roundoff errors.\n\ 571 To correct for precision problems, do not use 'Q0'. By default, Qhull\n\ 572 selects 'C-0' or 'Qx' and merges non-convex facets. With option 'QJ',\n\ 573 Qhull joggles the input to prevent precision problems. See \"Imprecision\n\ 574 in Qhull\" (qh-impre.htm).\n\ 576 If you use 'Q0', the output may include\n\ 577 coplanar ridges, concave ridges, and flipped facets. In 4-d and higher,\n\ 578 Qhull may produce a ridge with four neighbors or two facets with the same \n\ 579 vertices. Qhull reports these events when they occur. It stops when a\n\ 580 concave ridge, flipped facet, or duplicate facet occurs.\n");
584 Qhull is currently using single precision arithmetic. The following\n\ 585 will probably remove the precision problems:\n\ 586 - recompile qhull for realT precision(#define REALfloat 0 in user.h).\n");
591 When computing the Delaunay triangulation of coordinates > 1.0,\n\ 592 - use 'Qbb' to scale the last coordinate to [0,m] (max previous coordinate)\n");
595 When computing the Delaunay triangulation:\n\ 596 - use 'Qz' to add a point at-infinity. This reduces precision problems.\n");
600 If you need triangular output:\n\ 601 - use option 'Qt' to triangulate the output\n\ 602 - use option 'QJ' to joggle the input points and remove precision errors\n\ 603 - use option 'Ft'. It triangulates non-simplicial facets with added points.\n\ 605 If you must use 'Q0',\n\ 606 try one or more of the following options. They can not guarantee an output.\n\ 607 - use 'QbB' to scale the input to a cube.\n\ 608 - use 'Po' to produce output and prevent partitioning for flipped facets\n\ 609 - use 'V0' to set min. distance to visible facet as 0 instead of roundoff\n\ 610 - use 'En' to specify a maximum roundoff error less than %2.2g.\n\ 611 - options 'Qf', 'Qbb', and 'QR0' may also help\n",
615 To guarantee simplicial output:\n\ 616 - use option 'Qt' to triangulate the output\n\ 617 - use option 'QJ' to joggle the input points and remove precision errors\n\ 618 - use option 'Ft' to triangulate the output by adding points\n\ 619 - use exact arithmetic (see \"Imprecision in Qhull\", qh-impre.htm)\n\ 634 qh_fprintf(qh, fp, 9375,
"qhull precision warning: \n\ 635 The initial hull is narrow (cosine of min. angle is %.16f).\n\ 636 A coplanar point may lead to a wide facet. Options 'QbB' (scale to unit box)\n\ 637 or 'Qbb' (scale last coordinate) may remove this warning. Use 'Pp' to skip\n\ 638 this warning. See 'Limitations' in qh-impre.htm.\n",
648 realT min, max, *coord, dist;
652 The input to qhull appears to be less than %d dimensional, or a\n\ 653 computation has overflowed.\n\n\ 654 Qhull could not construct a clearly convex simplex from points:\n",
659 The center point is coplanar with a facet, or a vertex is coplanar\n\ 660 with a neighboring facet. The maximum round off error for\n\ 661 computing distances is %2.2g. The center point, facets and distances\n\ 662 to the center point are as follows:\n\n", qh->
DISTround);
671 qh_fprintf(qh, fp, 9381,
" distance= %4.2g\n", dist);
676 These points are the dual of the given halfspaces. They indicate that\n\ 677 the intersection is degenerate.\n");
679 These points either have a maximum or minimum x-coordinate, or\n\ 680 they maximize the determinant for k coordinates. Trial points\n\ 681 are first selected from points that maximize a coordinate.\n");
684 Because of the high dimension, the min x-coordinate and max-coordinate\n\ 685 points are used if the determinant is non-zero. Option 'Qs' will\n\ 686 do a better, though much slower, job. Instead of 'Qs', you can change\n\ 687 the points by randomly rotating the input with 'QR0'.\n");
689 qh_fprintf(qh, fp, 9385,
"\nThe min and max coordinates for each dimension are:\n");
697 qh_fprintf(qh, fp, 9386,
" %d: %8.4g %8.4g difference= %4.4g\n", k, min, max, max-min);
701 If the input should be full dimensional, you have several options that\n\ 702 may determine an initial simplex:\n\ 703 - use 'QJ' to joggle the input and make it full dimensional\n\ 704 - use 'QbB' to scale the points to the unit cube\n\ 705 - use 'QR0' to randomly rotate the input for different maximum points\n\ 706 - use 'Qs' to search all points for the initial simplex\n\ 707 - use 'En' to specify a maximum roundoff error less than %2.2g.\n\ 708 - trace execution with 'T3' to see the determinant for each point.\n",
712 - recompile qhull for realT precision(#define REALfloat 0 in libqhull.h).\n");
715 If the input is lower dimensional:\n\ 716 - use 'QJ' to joggle the input and make it full dimensional\n\ 717 - use 'Qbk:0Bk:0' to delete coordinate k from the input. You should\n\ 718 pick the coordinate with the least range. The hull will have the\n\ 720 - determine the flat containing the points, rotate the points\n\ 721 into a coordinate plane, and delete the other coordinates.\n\ 722 - add one or more points to make the input full dimensional.\n\ 726 This is a Delaunay triangulation and the input is co-circular or co-spherical:\n\ 727 - use 'Qz' to add a point \"at infinity\" (i.e., above the paraboloid)\n\ 728 - or use 'QJ' to joggle the input and avoid co-circular data\n");
void print_summary(qhT *qh)
facetT * qh_findbestfacet(pointT *point, boolT bestoutside, realT *bestdist, boolT *isoutside)
void seed(unsigned int seed_value)
void addhalf(qhT *qh, coordT *points, int numpoints, int numnew, int dim, coordT *feasible)
int main(int argc, char *argv[])
#define FOREACHvertex_(vertices)
void qh_printpoint(FILE *fp, const char *string, pointT *point)
void qh_printhelp_singular(qhT *qh, FILE *fp)
void qh_fprintf(FILE *fp, int msgcode, const char *fmt,...)
coordT * qh_sethalfspace_all(int dim, int count, coordT *halfspaces, pointT *feasible)
void qh_check_output(void)
void qh_printend(FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall)
#define FORALLfacet_(facetlist)
void adddiamond(qhT *qh, coordT *points, int numpoints, int numnew, int dim)
int qh_pointid(pointT *point)
void addDelaunay(qhT *qh, coordT *points, int numpoints, int numnew, int dim)
void qh_nearcoplanar(void)
void qh_init_A(FILE *infile, FILE *outfile, FILE *errfile, int argc, char *argv[])
boolT qh_addpoint(pointT *furthest, facetT *facet, boolT checkdist)
void qh_triangulate(void)
boolT qh_sethalfspace(int dim, coordT *coords, coordT **nextp, coordT *normal, coordT *offset, coordT *feasible)
void qh_printhelp_degenerate(qhT *qh, FILE *fp)
void qh_check_points(void)
void qh_setdelaunay(int dim, int count, pointT *points)
void qh_printpointid(FILE *fp, const char *string, int dim, pointT *point, int id)
void qh_errprint(qhT *qh, const char *string, facetT *atfacet, facetT *otherfacet, ridgeT *atridge, vertexT *atvertex)
void qh_produce_output(void)
void qh_freeqhull(boolT allmem)
#define maximize_(maxval, val)
void findDelaunay(qhT *qh, int dim)
void qh_init_B(coordT *points, int numpoints, int dim, boolT ismalloc)
void qh_setfeasible(int dim)
#define FOREACHfacet_(facets)
void qh_printbegin(FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall)
void qh_printhelp_narrowhull(qhT *qh, FILE *fp, realT minangle)
void qh_memfreeshort(int *curlong, int *totlong)
void qh_user_memsizes(qhT *qh)
void makehalf(coordT *points, int numpoints, int dim)
void makeDelaunay(qhT *qh, coordT *points, int numpoints, int dim)
void qh_printafacet(FILE *fp, qh_PRINT format, facetT *facet, boolT printall)
void qh_check_maxout(void)
void qh_initflags(char *command)
void qh_errexit(qhT *qh, int exitcode, facetT *facet, ridgeT *ridge)
void qh_distplane(pointT *point, facetT *facet, realT *dist)
int qh_setsize(setT *set)
#define qh_RANDOMseed_(seed)
void qh_printfacetlist(qhT *qh, facetT *facetlist, setT *facets, boolT printall)
void makecube(coordT *points, int numpoints, int dim)
void qh_printvertexlist(FILE *fp, const char *string, facetT *facetlist, setT *facets, boolT printall)
#define minimize_(minval, val)