geom_r.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*<html><pre> -<a href="qh-geom_r.htm"
  2. >-------------------------------</a><a name="TOP">-</a>
  3. geom_r.h
  4. header file for geometric routines
  5. see qh-geom_r.htm and geom_r.c
  6. Copyright (c) 1993-2020 The Geometry Center.
  7. $Id: //main/2019/qhull/src/libqhull_r/geom_r.h#2 $$Change: 2953 $
  8. $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $
  9. */
  10. #ifndef qhDEFgeom
  11. #define qhDEFgeom 1
  12. #include "libqhull_r.h"
  13. /* ============ -macros- ======================== */
  14. /*-<a href="qh-geom_r.htm#TOC"
  15. >--------------------------------</a><a name="fabs_">-</a>
  16. fabs_(a)
  17. returns the absolute value of a
  18. */
  19. #define fabs_( a ) ((( a ) < 0 ) ? -( a ):( a ))
  20. /*-<a href="qh-geom_r.htm#TOC"
  21. >--------------------------------</a><a name="fmax_">-</a>
  22. fmax_(a,b)
  23. returns the maximum value of a and b
  24. */
  25. #define fmax_( a,b ) ( ( a ) < ( b ) ? ( b ) : ( a ) )
  26. /*-<a href="qh-geom_r.htm#TOC"
  27. >--------------------------------</a><a name="fmin_">-</a>
  28. fmin_(a,b)
  29. returns the minimum value of a and b
  30. */
  31. #define fmin_( a,b ) ( ( a ) > ( b ) ? ( b ) : ( a ) )
  32. /*-<a href="qh-geom_r.htm#TOC"
  33. >--------------------------------</a><a name="maximize_">-</a>
  34. maximize_(maxval, val)
  35. set maxval to val if val is greater than maxval
  36. */
  37. #define maximize_( maxval, val ) { if (( maxval ) < ( val )) ( maxval )= ( val ); }
  38. /*-<a href="qh-geom_r.htm#TOC"
  39. >--------------------------------</a><a name="minimize_">-</a>
  40. minimize_(minval, val)
  41. set minval to val if val is less than minval
  42. */
  43. #define minimize_( minval, val ) { if (( minval ) > ( val )) ( minval )= ( val ); }
  44. /*-<a href="qh-geom_r.htm#TOC"
  45. >--------------------------------</a><a name="det2_">-</a>
  46. det2_(a1, a2,
  47. b1, b2)
  48. compute a 2-d determinate
  49. */
  50. #define det2_( a1,a2,b1,b2 ) (( a1 )*( b2 ) - ( a2 )*( b1 ))
  51. /*-<a href="qh-geom_r.htm#TOC"
  52. >--------------------------------</a><a name="det3_">-</a>
  53. det3_(a1, a2, a3,
  54. b1, b2, b3,
  55. c1, c2, c3)
  56. compute a 3-d determinate
  57. */
  58. #define det3_( a1,a2,a3,b1,b2,b3,c1,c2,c3 ) ( ( a1 )*det2_( b2,b3,c2,c3 ) \
  59. - ( b1 )*det2_( a2,a3,c2,c3 ) + ( c1 )*det2_( a2,a3,b2,b3 ) )
  60. /*-<a href="qh-geom_r.htm#TOC"
  61. >--------------------------------</a><a name="dX">-</a>
  62. dX( p1, p2 )
  63. dY( p1, p2 )
  64. dZ( p1, p2 )
  65. given two indices into rows[],
  66. compute the difference between X, Y, or Z coordinates
  67. */
  68. #define dX( p1,p2 ) ( *( rows[p1] ) - *( rows[p2] ))
  69. #define dY( p1,p2 ) ( *( rows[p1]+1 ) - *( rows[p2]+1 ))
  70. #define dZ( p1,p2 ) ( *( rows[p1]+2 ) - *( rows[p2]+2 ))
  71. #define dW( p1,p2 ) ( *( rows[p1]+3 ) - *( rows[p2]+3 ))
  72. /*============= prototypes in alphabetical order, infrequent at end ======= */
  73. #ifdef __cplusplus
  74. extern "C" {
  75. #endif
  76. void qh_backnormal(qhT *qh, realT **rows, int numrow, int numcol, boolT sign, coordT *normal, boolT *nearzero);
  77. void qh_distplane(qhT *qh, pointT *point, facetT *facet, realT *dist);
  78. facetT *qh_findbest(qhT *qh, pointT *point, facetT *startfacet,
  79. boolT bestoutside, boolT isnewfacets, boolT noupper,
  80. realT *dist, boolT *isoutside, int *numpart);
  81. facetT *qh_findbesthorizon(qhT *qh, boolT ischeckmax, pointT *point,
  82. facetT *startfacet, boolT noupper, realT *bestdist, int *numpart);
  83. facetT *qh_findbestnew(qhT *qh, pointT *point, facetT *startfacet, realT *dist,
  84. boolT bestoutside, boolT *isoutside, int *numpart);
  85. void qh_gausselim(qhT *qh, realT **rows, int numrow, int numcol, boolT *sign, boolT *nearzero);
  86. realT qh_getangle(qhT *qh, pointT *vect1, pointT *vect2);
  87. pointT *qh_getcenter(qhT *qh, setT *vertices);
  88. pointT *qh_getcentrum(qhT *qh, facetT *facet);
  89. coordT qh_getdistance(qhT *qh, facetT *facet, facetT *neighbor, coordT *mindist, coordT *maxdist);
  90. void qh_normalize(qhT *qh, coordT *normal, int dim, boolT toporient);
  91. void qh_normalize2(qhT *qh, coordT *normal, int dim, boolT toporient,
  92. realT *minnorm, boolT *ismin);
  93. pointT *qh_projectpoint(qhT *qh, pointT *point, facetT *facet, realT dist);
  94. void qh_setfacetplane(qhT *qh, facetT *newfacets);
  95. void qh_sethyperplane_det(qhT *qh, int dim, coordT **rows, coordT *point0,
  96. boolT toporient, coordT *normal, realT *offset, boolT *nearzero);
  97. void qh_sethyperplane_gauss(qhT *qh, int dim, coordT **rows, pointT *point0,
  98. boolT toporient, coordT *normal, coordT *offset, boolT *nearzero);
  99. boolT qh_sharpnewfacets(qhT *qh);
  100. /*========= infrequently used code in geom2_r.c =============*/
  101. coordT *qh_copypoints(qhT *qh, coordT *points, int numpoints, int dimension);
  102. void qh_crossproduct(int dim, realT vecA[3], realT vecB[3], realT vecC[3]);
  103. realT qh_determinant(qhT *qh, realT **rows, int dim, boolT *nearzero);
  104. realT qh_detjoggle(qhT *qh, pointT *points, int numpoints, int dimension);
  105. void qh_detmaxoutside(qhT *qh);
  106. void qh_detroundoff(qhT *qh);
  107. realT qh_detsimplex(qhT *qh, pointT *apex, setT *points, int dim, boolT *nearzero);
  108. realT qh_distnorm(int dim, pointT *point, pointT *normal, realT *offsetp);
  109. realT qh_distround(qhT *qh, int dimension, realT maxabs, realT maxsumabs);
  110. realT qh_divzero(realT numer, realT denom, realT mindenom1, boolT *zerodiv);
  111. realT qh_facetarea(qhT *qh, facetT *facet);
  112. realT qh_facetarea_simplex(qhT *qh, int dim, coordT *apex, setT *vertices,
  113. vertexT *notvertex, boolT toporient, coordT *normal, realT *offset);
  114. pointT *qh_facetcenter(qhT *qh, setT *vertices);
  115. facetT *qh_findgooddist(qhT *qh, pointT *point, facetT *facetA, realT *distp, facetT **facetlist);
  116. vertexT *qh_furthestnewvertex(qhT *qh, unsigned int unvisited, facetT *facet, realT *maxdistp /* qh.newvertex_list */);
  117. vertexT *qh_furthestvertex(qhT *qh, facetT *facetA, facetT *facetB, realT *maxdistp, realT *mindistp);
  118. void qh_getarea(qhT *qh, facetT *facetlist);
  119. boolT qh_gram_schmidt(qhT *qh, int dim, realT **rows);
  120. boolT qh_inthresholds(qhT *qh, coordT *normal, realT *angle);
  121. void qh_joggleinput(qhT *qh);
  122. realT *qh_maxabsval(realT *normal, int dim);
  123. setT *qh_maxmin(qhT *qh, pointT *points, int numpoints, int dimension);
  124. realT qh_maxouter(qhT *qh);
  125. void qh_maxsimplex(qhT *qh, int dim, setT *maxpoints, pointT *points, int numpoints, setT **simplex);
  126. realT qh_minabsval(realT *normal, int dim);
  127. int qh_mindiff(realT *vecA, realT *vecB, int dim);
  128. boolT qh_orientoutside(qhT *qh, facetT *facet);
  129. void qh_outerinner(qhT *qh, facetT *facet, realT *outerplane, realT *innerplane);
  130. coordT qh_pointdist(pointT *point1, pointT *point2, int dim);
  131. void qh_printmatrix(qhT *qh, FILE *fp, const char *string, realT **rows, int numrow, int numcol);
  132. void qh_printpoints(qhT *qh, FILE *fp, const char *string, setT *points);
  133. void qh_projectinput(qhT *qh);
  134. void qh_projectpoints(qhT *qh, signed char *project, int n, realT *points,
  135. int numpoints, int dim, realT *newpoints, int newdim);
  136. void qh_rotateinput(qhT *qh, realT **rows);
  137. void qh_rotatepoints(qhT *qh, realT *points, int numpoints, int dim, realT **rows);
  138. void qh_scaleinput(qhT *qh);
  139. void qh_scalelast(qhT *qh, coordT *points, int numpoints, int dim, coordT low,
  140. coordT high, coordT newhigh);
  141. void qh_scalepoints(qhT *qh, pointT *points, int numpoints, int dim,
  142. realT *newlows, realT *newhighs);
  143. boolT qh_sethalfspace(qhT *qh, int dim, coordT *coords, coordT **nextp,
  144. coordT *normal, coordT *offset, coordT *feasible);
  145. coordT *qh_sethalfspace_all(qhT *qh, int dim, int count, coordT *halfspaces, pointT *feasible);
  146. coordT qh_vertex_bestdist(qhT *qh, setT *vertices);
  147. coordT qh_vertex_bestdist2(qhT *qh, setT *vertices, vertexT **vertexp, vertexT **vertexp2);
  148. pointT *qh_voronoi_center(qhT *qh, int dim, setT *points);
  149. #ifdef __cplusplus
  150. } /* extern "C"*/
  151. #endif
  152. #endif /* qhDEFgeom */