2 double const epsilon = 1.1102230246251565e-016;
6 boost::array<double,2> A1,A2;
9 double acx, acy, bcx, bcy, acxtail, acytail, bcxtail, bcytail;
10 double detLeft, detRight, detLeftErr, detRightErr, det, err;
11 double s1, t1, s0, t0;
13 double resultErrBound = (3.0 + 8.0 * epsilon) * epsilon;
14 double errBoundB = (2.0 + 12.0 * epsilon) * epsilon;
15 double errBoundC = (9.0 + 64.0 * epsilon) * epsilon * epsilon;
30 err = errBoundB * detsum;
32 if ((det >= err) || (-det >= err))
36 if ((acxtail == 0.0) && (acytail == 0.0) && (bcxtail == 0.0) && (bcytail == 0.0))
40 err = errBoundC * detsum + resultErrBound * fabs(det);
41 det += (acx * bcytail + bcy * acxtail) - (acy * bcxtail + bcx * acytail);
42 if ((det >= err) || (-det >= err))
78 double detleft, detright, det;
79 double detsum, errbound;
80 double errBoundA = (3.0 + 16.0 * epsilon) * epsilon;
85 det = detleft - detright;
95 detsum = detleft + detright;
108 detsum = -detleft - detright;
116 errbound = errBoundA * detsum;
117 if ((det >= errbound) || (-det >= errbound))
130 double adx, bdx, cdx, ady, bdy, cdy;
131 double adxtail, bdxtail, cdxtail, adytail, bdytail, cdytail;
132 double bdxcdy1, cdxbdy1, cdxady1, adxcdy1, adxbdy1, bdxady1;
133 double bdxcdy0, cdxbdy0, cdxady0, adxcdy0, adxbdy0, bdxady0;
134 double res1, res2, err1, err2;
135 double det, errbound;
137 double errBoundB = (4.0 + 48.0 * epsilon) * epsilon;
138 double errBoundC = (44.0 + 576.0 * epsilon) * epsilon * epsilon;
139 double resultErrBound = (3.0 + 8.0 * epsilon) * epsilon;
141 boost::array<double,2> A1, A2;
142 vector<double> B1, B2, B3, C1, C2, C3, D1, D2, D3, E1, E2, E3, F;
143 vector<double> tmp1, tmp2;
145 twoDiff(point_1.
x, point_4.
x, adx, adxtail);
146 twoDiff(point_2.
x, point_4.
x, bdx, bdxtail);
147 twoDiff(point_3.
x, point_4.
x, cdx, cdxtail);
148 twoDiff(point_1.
y, point_4.
y, ady, adytail);
149 twoDiff(point_2.
y, point_4.
y, bdy, bdytail);
150 twoDiff(point_3.
y, point_4.
y, cdy, cdytail);
195 errbound = errBoundB * permanent;
196 if ((det >= errbound) || (-det >= errbound))
200 if ((adxtail == 0.0) && (bdxtail == 0.0) && (cdxtail == 0.0)
201 && (adytail == 0.0) && (bdytail == 0.0) && (cdytail == 0.0))
205 errbound = errBoundC * permanent + resultErrBound * fabs(det);
206 det += ((adx * adx + ady * ady) * ((bdx * cdytail + cdy * bdxtail)
207 - (bdy * cdxtail + cdx * bdytail)) + 2.0 * (adx * adxtail + ady * adytail)
208 * (bdx * cdy - bdy * cdx)) + ((bdx * bdx + bdy * bdy) * ((cdx * adytail + ady * cdxtail)
209 - (cdy * adxtail + adx * cdytail)) + 2.0 * (bdx * bdxtail + bdy * bdytail) * (cdx * ady - cdy * adx))
210 + ((cdx * cdx + cdy * cdy) * ((adx * bdytail + bdy * adxtail) - (ady * bdxtail + bdx * adytail))
211 + 2.0 * (cdx * cdxtail + cdy * cdytail) * (adx * bdy - ady * bdx));
212 if ((det >= errbound) || (-det >= errbound))
218 if ((bdxtail != 0.0) || (bdytail != 0.0) || (cdxtail != 0.0) || (cdytail != 0.0))
224 square(adx, adxadx1, adxadx0);
225 square(ady, adyady1, adyady0);
232 if ((cdxtail != 0.0) || (cdytail != 0.0) || (adxtail != 0.0) || (adytail != 0.0))
238 square(bdx, bdxbdx1, bdxbdx0);
239 square(bdy, bdybdy1, bdybdy0);
246 if ((adxtail != 0.0) || (adytail != 0.0) || (bdxtail != 0.0) || (bdytail != 0.0))
252 square(cdx, cdxcdx1, cdxcdx0);
253 square(cdy, cdycdy1, cdycdy0);
262 vector<double> helper;
277 vector<double> helper;
288 vector<double> helper;
301 vector<double> helper;
314 vector<double> helper;
327 vector<double> helper;
339 if ((adxtail != 0.0) || (adytail != 0.0))
341 if ((bdxtail != 0.0) || (bdytail != 0.0) || (cdxtail != 0.0) || (cdytail != 0.0))
414 if ((bdxtail != 0.0) || (bdytail != 0.0))
416 if ((cdxtail != 0.0) || (cdytail != 0.0) || (adxtail != 0.0) || (adytail != 0.0))
489 if ((cdxtail != 0.0) || (cdytail != 0.0))
491 if ((adxtail != 0.0) || (adytail != 0.0) || (bdxtail != 0.0) || (bdytail != 0.0))
572 const double errBoundA = (10.0 + 96.0 * epsilon) * epsilon;
574 const double adx = point_1.
x - point_4.
x;
575 const double bdx = point_2.
x - point_4.
x;
576 const double cdx = point_3.
x - point_4.
x;
577 const double ady = point_1.
y - point_4.
y;
578 const double bdy = point_2.
y - point_4.
y;
579 const double cdy = point_3.
y - point_4.
y;
581 const double alift = adx * adx + ady * ady;
582 const double blift = bdx * bdx + bdy * bdy;
583 const double clift = cdx * cdx + cdy * cdy;
584 const double bdxcdy = bdx * cdy;
585 const double cdxbdy = cdx * bdy;
586 const double cdxady = cdx * ady;
587 const double adxcdy = adx * cdy;
588 const double adxbdy = adx * bdy;
589 const double bdxady = bdx * ady;
592 const double det = alift * (bdxcdy - cdxbdy) + blift * (cdxady - adxcdy) + clift * (adxbdy - bdxady);
594 const double permanent = (fabs(bdxcdy) + fabs(cdxbdy)) * alift
595 + (fabs(cdxady) + fabs(adxcdy)) * blift
596 + (fabs(adxbdy) + fabs(bdxady)) * clift;
597 const double errbound = errBoundA * permanent;
598 if ((det > errbound) || (-det > errbound))
const T & third
Reference to third item.
void twoDiff(double a, double b, double &res, double &err)
Difference between two numbers.
Various checks for geometric data.
double incircle(const Vector2D &point_1, const Vector2D &point_2, const Vector2D &point_3, const Vector2D &point_4)
Checks whether the 4th point is inside, outside or on the counterclockwise circle created by the firs...
const T & second
Reference to second item.
double incircleadapt(const Vector2D &point_1, const Vector2D &point_2, const Vector2D &point_3, const Vector2D &point_4, double permanent)
Checks whether the 4th point is inside, outside or on the counterclockwise circle created by the firs...
double estimate(vector< double > const &e)
Calculate a double precision approximation of the expansion.
vector< double > twoTwoSum(boost::array< double, 2 > const &a, boost::array< double, 2 > const &b)
Calculates the sum of two two-expansions.
void twoProduct(double a, double b, double &res, double &err)
Product of two number.
double y
Component in the y direction.
A collection of three identical references.
vector< double > twoTwoDiff(boost::array< double, 2 > const &a, boost::array< double, 2 > const &b)
Calculates the difference between two two-expansions.
double orient2dAdapt(const TripleConstRef< Vector2D > &points, double detsum)
Checks whether 3 given points are on a counterclockwise circle, clockwise circle or colinear using ad...
const T & first
Reference to first item.
vector< double > fastExpansionSumZeroElim(vector< double > const &e, vector< double > const &f)
Adds up two expansions.
void scaleExpansionZeroElim(vector< double > const &e, double b, vector< double > &result)
Multiplies a scalar by an expansion.
double orient2d(const TripleConstRef< Vector2D > &points)
Checks whether 3 given points are on a counterclockwise circle, clockwise circle or colinear...
double x
Component in the x direction.
void square(double num, double &res, double &err)
Calculates the square of a number.