Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:19:26

0001 /*<html><pre>  -<a                             href="qh-geom_r.htm"
0002   >-------------------------------</a><a name="TOP">-</a>
0003 
0004   geom_r.h
0005     header file for geometric routines
0006 
0007    see qh-geom_r.htm and geom_r.c
0008 
0009    Copyright (c) 1993-2020 The Geometry Center.
0010    $Id: //main/2019/qhull/src/libqhull_r/geom_r.h#2 $$Change: 2953 $
0011    $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $
0012 */
0013 
0014 #ifndef qhDEFgeom
0015 #define qhDEFgeom 1
0016 
0017 #include "libqhull_r.h"
0018 
0019 /* ============ -macros- ======================== */
0020 
0021 /*-<a                             href="qh-geom_r.htm#TOC"
0022   >--------------------------------</a><a name="fabs_">-</a>
0023 
0024   fabs_(a)
0025     returns the absolute value of a
0026 */
0027 #define fabs_( a ) ((( a ) < 0 ) ? -( a ):( a ))
0028 
0029 /*-<a                             href="qh-geom_r.htm#TOC"
0030   >--------------------------------</a><a name="fmax_">-</a>
0031 
0032   fmax_(a,b)
0033     returns the maximum value of a and b
0034 */
0035 #define fmax_( a,b )  ( ( a ) < ( b ) ? ( b ) : ( a ) )
0036 
0037 /*-<a                             href="qh-geom_r.htm#TOC"
0038   >--------------------------------</a><a name="fmin_">-</a>
0039 
0040   fmin_(a,b)
0041     returns the minimum value of a and b
0042 */
0043 #define fmin_( a,b )  ( ( a ) > ( b ) ? ( b ) : ( a ) )
0044 
0045 /*-<a                             href="qh-geom_r.htm#TOC"
0046   >--------------------------------</a><a name="maximize_">-</a>
0047 
0048   maximize_(maxval, val)
0049     set maxval to val if val is greater than maxval
0050 */
0051 #define maximize_( maxval, val ) { if (( maxval ) < ( val )) ( maxval )= ( val ); }
0052 
0053 /*-<a                             href="qh-geom_r.htm#TOC"
0054   >--------------------------------</a><a name="minimize_">-</a>
0055 
0056   minimize_(minval, val)
0057     set minval to val if val is less than minval
0058 */
0059 #define minimize_( minval, val ) { if (( minval ) > ( val )) ( minval )= ( val ); }
0060 
0061 /*-<a                             href="qh-geom_r.htm#TOC"
0062   >--------------------------------</a><a name="det2_">-</a>
0063 
0064   det2_(a1, a2,
0065         b1, b2)
0066 
0067     compute a 2-d determinate
0068 */
0069 #define det2_( a1,a2,b1,b2 ) (( a1 )*( b2 ) - ( a2 )*( b1 ))
0070 
0071 /*-<a                             href="qh-geom_r.htm#TOC"
0072   >--------------------------------</a><a name="det3_">-</a>
0073 
0074   det3_(a1, a2, a3,
0075        b1, b2, b3,
0076        c1, c2, c3)
0077 
0078     compute a 3-d determinate
0079 */
0080 #define det3_( a1,a2,a3,b1,b2,b3,c1,c2,c3 ) ( ( a1 )*det2_( b2,b3,c2,c3 ) \
0081                 - ( b1 )*det2_( a2,a3,c2,c3 ) + ( c1 )*det2_( a2,a3,b2,b3 ) )
0082 
0083 /*-<a                             href="qh-geom_r.htm#TOC"
0084   >--------------------------------</a><a name="dX">-</a>
0085 
0086   dX( p1, p2 )
0087   dY( p1, p2 )
0088   dZ( p1, p2 )
0089 
0090     given two indices into rows[],
0091 
0092     compute the difference between X, Y, or Z coordinates
0093 */
0094 #define dX( p1,p2 )  ( *( rows[p1] ) - *( rows[p2] ))
0095 #define dY( p1,p2 )  ( *( rows[p1]+1 ) - *( rows[p2]+1 ))
0096 #define dZ( p1,p2 )  ( *( rows[p1]+2 ) - *( rows[p2]+2 ))
0097 #define dW( p1,p2 )  ( *( rows[p1]+3 ) - *( rows[p2]+3 ))
0098 
0099 /*============= prototypes in alphabetical order, infrequent at end ======= */
0100 
0101 #ifdef __cplusplus
0102 extern "C" {
0103 #endif
0104 
0105 void    qh_backnormal(qhT *qh, realT **rows, int numrow, int numcol, boolT sign, coordT *normal, boolT *nearzero);
0106 void    qh_distplane(qhT *qh, pointT *point, facetT *facet, realT *dist);
0107 facetT *qh_findbest(qhT *qh, pointT *point, facetT *startfacet,
0108                      boolT bestoutside, boolT isnewfacets, boolT noupper,
0109                      realT *dist, boolT *isoutside, int *numpart);
0110 facetT *qh_findbesthorizon(qhT *qh, boolT ischeckmax, pointT *point,
0111                      facetT *startfacet, boolT noupper, realT *bestdist, int *numpart);
0112 facetT *qh_findbestnew(qhT *qh, pointT *point, facetT *startfacet, realT *dist,
0113                      boolT bestoutside, boolT *isoutside, int *numpart);
0114 void    qh_gausselim(qhT *qh, realT **rows, int numrow, int numcol, boolT *sign, boolT *nearzero);
0115 realT   qh_getangle(qhT *qh, pointT *vect1, pointT *vect2);
0116 pointT *qh_getcenter(qhT *qh, setT *vertices);
0117 pointT *qh_getcentrum(qhT *qh, facetT *facet);
0118 coordT  qh_getdistance(qhT *qh, facetT *facet, facetT *neighbor, coordT *mindist, coordT *maxdist);
0119 void    qh_normalize(qhT *qh, coordT *normal, int dim, boolT toporient);
0120 void    qh_normalize2(qhT *qh, coordT *normal, int dim, boolT toporient,
0121             realT *minnorm, boolT *ismin);
0122 pointT *qh_projectpoint(qhT *qh, pointT *point, facetT *facet, realT dist);
0123 
0124 void    qh_setfacetplane(qhT *qh, facetT *newfacets);
0125 void    qh_sethyperplane_det(qhT *qh, int dim, coordT **rows, coordT *point0,
0126               boolT toporient, coordT *normal, realT *offset, boolT *nearzero);
0127 void    qh_sethyperplane_gauss(qhT *qh, int dim, coordT **rows, pointT *point0,
0128              boolT toporient, coordT *normal, coordT *offset, boolT *nearzero);
0129 boolT   qh_sharpnewfacets(qhT *qh);
0130 
0131 /*========= infrequently used code in geom2_r.c =============*/
0132 
0133 coordT *qh_copypoints(qhT *qh, coordT *points, int numpoints, int dimension);
0134 void    qh_crossproduct(int dim, realT vecA[3], realT vecB[3], realT vecC[3]);
0135 realT   qh_determinant(qhT *qh, realT **rows, int dim, boolT *nearzero);
0136 realT   qh_detjoggle(qhT *qh, pointT *points, int numpoints, int dimension);
0137 void    qh_detmaxoutside(qhT *qh);
0138 void    qh_detroundoff(qhT *qh);
0139 realT   qh_detsimplex(qhT *qh, pointT *apex, setT *points, int dim, boolT *nearzero);
0140 realT   qh_distnorm(int dim, pointT *point, pointT *normal, realT *offsetp);
0141 realT   qh_distround(qhT *qh, int dimension, realT maxabs, realT maxsumabs);
0142 realT   qh_divzero(realT numer, realT denom, realT mindenom1, boolT *zerodiv);
0143 realT   qh_facetarea(qhT *qh, facetT *facet);
0144 realT   qh_facetarea_simplex(qhT *qh, int dim, coordT *apex, setT *vertices,
0145           vertexT *notvertex,  boolT toporient, coordT *normal, realT *offset);
0146 pointT *qh_facetcenter(qhT *qh, setT *vertices);
0147 facetT *qh_findgooddist(qhT *qh, pointT *point, facetT *facetA, realT *distp, facetT **facetlist);
0148 vertexT *qh_furthestnewvertex(qhT *qh, unsigned int unvisited, facetT *facet, realT *maxdistp /* qh.newvertex_list */);
0149 vertexT *qh_furthestvertex(qhT *qh, facetT *facetA, facetT *facetB, realT *maxdistp, realT *mindistp);
0150 void    qh_getarea(qhT *qh, facetT *facetlist);
0151 boolT   qh_gram_schmidt(qhT *qh, int dim, realT **rows);
0152 boolT   qh_inthresholds(qhT *qh, coordT *normal, realT *angle);
0153 void    qh_joggleinput(qhT *qh);
0154 realT  *qh_maxabsval(realT *normal, int dim);
0155 setT   *qh_maxmin(qhT *qh, pointT *points, int numpoints, int dimension);
0156 realT   qh_maxouter(qhT *qh);
0157 void    qh_maxsimplex(qhT *qh, int dim, setT *maxpoints, pointT *points, int numpoints, setT **simplex);
0158 realT   qh_minabsval(realT *normal, int dim);
0159 int     qh_mindiff(realT *vecA, realT *vecB, int dim);
0160 boolT   qh_orientoutside(qhT *qh, facetT *facet);
0161 void    qh_outerinner(qhT *qh, facetT *facet, realT *outerplane, realT *innerplane);
0162 coordT  qh_pointdist(pointT *point1, pointT *point2, int dim);
0163 void    qh_printmatrix(qhT *qh, FILE *fp, const char *string, realT **rows, int numrow, int numcol);
0164 void    qh_printpoints(qhT *qh, FILE *fp, const char *string, setT *points);
0165 void    qh_projectinput(qhT *qh);
0166 void    qh_projectpoints(qhT *qh, signed char *project, int n, realT *points,
0167              int numpoints, int dim, realT *newpoints, int newdim);
0168 void    qh_rotateinput(qhT *qh, realT **rows);
0169 void    qh_rotatepoints(qhT *qh, realT *points, int numpoints, int dim, realT **rows);
0170 void    qh_scaleinput(qhT *qh);
0171 void    qh_scalelast(qhT *qh, coordT *points, int numpoints, int dim, coordT low,
0172                    coordT high, coordT newhigh);
0173 void    qh_scalepoints(qhT *qh, pointT *points, int numpoints, int dim,
0174                 realT *newlows, realT *newhighs);
0175 boolT   qh_sethalfspace(qhT *qh, int dim, coordT *coords, coordT **nextp,
0176               coordT *normal, coordT *offset, coordT *feasible);
0177 coordT *qh_sethalfspace_all(qhT *qh, int dim, int count, coordT *halfspaces, pointT *feasible);
0178 coordT  qh_vertex_bestdist(qhT *qh, setT *vertices);
0179 coordT  qh_vertex_bestdist2(qhT *qh, setT *vertices, vertexT **vertexp, vertexT **vertexp2);
0180 pointT *qh_voronoi_center(qhT *qh, int dim, setT *points);
0181 
0182 #ifdef __cplusplus
0183 } /* extern "C"*/
0184 #endif
0185 
0186 #endif /* qhDEFgeom */
0187 
0188 
0189