Overture  Version 25
ShewchukPredicates.h
Go to the documentation of this file.
1 #ifndef __SHEW_PREDICATES__
2 #define __SHEW_PREDICATES__
3 
4 // interface to Jonathan Shewchuk's robust predicates, compiled in TriangleSource.c
5 
6 extern "C" {
7 /* orient2d(pa, pb, pc) */
8 extern double orient2d(double *, double*, double*);
9 
10 /* orient2dfast(pa, pb, pc) */
11 extern double orient2dfast(double *, double*, double*);
12 
13 /* orient3d(pa, pb, pc, pd) */
14 extern double orient3d(double *, double *, double *, double *);
15 
16 /* orient3dfast(pa, pb, pc, pd) */
17 extern double orient3d(double *, double *, double *, double *);
18 
19 /* incircle(pa, pb, pc, pd) */
20 extern double incircle(double *, double *, double *, double *);
21 
22 /* incirclefast(pa, pb, pc, pd) */
23 extern double iancirclefast(double *, double *, double *,double *);
24 
25 /* insphere(pa, pb, pc, pd, pe) */
26 extern double insphere(double *, double *, double *, double *, double *);
27 
28 /* inspherefast(pa, pb, pc, pd, pe) */
29 extern double inspherefast(double *, double *, double *, double *, double *);
30 }
31 
32 // single precision c++ interface for overture
33 
34 inline double orient2d(float *pa_, float *pb_, float *pc_)
35 {
36  double pa[2],pb[2],pc[2];
37  for ( int i=0; i<2; i++ )
38  {
39  pa[i] = pa_[i];
40  pb[i] = pb_[i];
41  pc[i] = pc_[i];
42  }
43  return orient2d(&pa[0],&pb[0],&pc[0]);
44 }
45 
46 /* orient3d(pa, pb, pc, pd) */
47 inline double orient3d(float *pa_, float *pb_, float *pc_, float *pd_)
48 {
49  double pa[3],pb[3],pc[3],pd[3];
50  for ( int i=0; i<3; i++ )
51  {
52  pa[i] = pa_[i];
53  pb[i] = pb_[i];
54  pc[i] = pc_[i];
55  pd[i] = pd_[i];
56  }
57  return orient3d(&pa[0],&pb[0],&pc[0],&pd[0]);
58 }
59 
60 /* incircle(pa, pb, pc, pd) */
61 inline double incircle(float *pa_, float *pb_, float *pc_, float *pd_)
62 {
63  double pa[2],pb[2],pc[2],pd[2];
64  for ( int i=0; i<2; i++ )
65  {
66  pa[i] = pa_[i];
67  pb[i] = pb_[i];
68  pc[i] = pc_[i];
69  pd[i] = pd_[i];
70  }
71  return incircle(&pa[0],&pb[0],&pc[0],&pd[0]);
72 }
73 
74 /* insphere(pa, pb, pc, pd, pe) */
75 inline double insphere(float *pa_, float *pb_, float *pc_, float *pd_, float *pe_)
76 {
77  double pa[3],pb[3],pc[3],pd[3],pe[3];
78  for ( int i=0; i<3; i++ )
79  {
80  pa[i] = pa_[i];
81  pb[i] = pb_[i];
82  pc[i] = pc_[i];
83  pd[i] = pd_[i];
84  pe[i] = pe_[i];
85  }
86  return insphere(&pa[0],&pb[0],&pc[0],&pd[0],&pe[0]);
87 }
88 
89 #endif