45 const double squareDiameter,
46 const double **theList,
50 const int _reduction_mode_ )
53 int index = first - 1;
65 double R = sqrt( squareDiameter );
66 double R2 = squareDiameter;
68 if ( first > *last )
return( first - 1 );
70 if ( squareDiameter <= theSeg->squareDiameter ) {
72 maxThreshold = medThreshold = 0.0;
77 minThreshold = (R - .86602540378443864676*ab)
78 * (R - .86602540378443864676*ab)
81 medThreshold = 0.5 * ab2 + 0.25 * R2
82 - .43301270189221932338 * R * sqrt( 4 * ab2 - R2 );
84 maxThreshold = 0.25 * (R2 - ab2);
93 switch ( _reduction_mode_ ) {
100 for ( i=first; i<=l; i++ ) {
103 if ( mamb > maxThreshold ) {
112 for ( i=first; i<=l; i++ ) {
115 if ( mamb > maxThreshold ) {
123 for ( i=first; i<=l; i++ ) {
126 if ( mamb > maxThreshold ) {
145 for ( i=first; i<=l; i++ ) {
148 if ( mamb > maxThreshold ) {
152 else if ( mamb <= minThreshold ) {
162 for ( i=first; i<=l; i++ ) {
165 if ( mamb > maxThreshold ) {
169 else if ( mamb <= minThreshold ) {
178 for ( i=first; i<=l; i++ ) {
181 if ( mamb > maxThreshold ) {
185 else if ( mamb <= minThreshold ) {
212 if ( squareDiameter <= theSeg->squareDiameter ) {
214 for ( i=first; i<=l; i++ ) {
217 if ( mamb > maxThreshold ) {
221 else if ( mamb > minThreshold ) {
223 if ( 3.0 * ( am2 * ab2 - (am2 - mamb)*(am2 - mamb) ) - mamb*mamb < 0 ) {
237 for ( i=first; i<=l; i++ ) {
240 if ( mamb > maxThreshold ) {
244 else if ( mamb > medThreshold ) {
247 else if ( mamb > minThreshold ) {
249 if ( 3.0 * ( am2 * ab2 - (am2 - mamb)*(am2 - mamb) )
250 - (R2 - ab2 - mamb)*(R2 - ab2 - mamb) < 0 ) {
269 if ( squareDiameter <= theSeg->squareDiameter ) {
271 for ( i=first; i<=l; i++ ) {
274 if ( mamb > maxThreshold ) {
278 else if ( mamb > minThreshold ) {
280 if ( 3.0 * ( am2 * ab2 - (am2 - mamb)*(am2 - mamb) ) - mamb*mamb < 0 ) {
294 for ( i=first; i<=l; i++ ) {
297 if ( mamb > maxThreshold ) {
301 else if ( mamb > medThreshold ) {
304 else if ( mamb > minThreshold ) {
306 if ( 3.0 * ( am2 * ab2 - (am2 - mamb)*(am2 - mamb) )
307 - (R2 - ab2 - mamb)*(R2 - ab2 - mamb) < 0 ) {
324 if ( squareDiameter <= theSeg->squareDiameter ) {
326 for ( i=first; i<=l; i++ ) {
329 if ( mamb > maxThreshold ) {
333 else if ( mamb > minThreshold ) {
335 if ( 3.0 * ( am2 * ab2 - (am2 - mamb)*(am2 - mamb) ) - mamb*mamb < 0 ) {
349 for ( i=first; i<=l; i++ ) {
352 if ( mamb > maxThreshold ) {
356 else if ( mamb > medThreshold ) {
359 else if ( mamb > minThreshold ) {
361 if ( 3.0 * ( am2 * ab2 - (am2 - mamb)*(am2 - mamb) )
362 - (R2 - ab2 - mamb)*(R2 - ab2 - mamb) < 0 ) {
387 const double squareDiameter,
388 const double **theList,
392 const int _reduction_mode_,
396 int index = first - 1;
408 double R = sqrt( squareDiameter );
409 double R2 = squareDiameter;
420 if ( squareDiameter <= theSeg->squareDiameter ) {
422 maxThreshold = medThreshold = 0.0;
426 theList, first, last, dim,
427 _reduction_mode_ ) );
431 minThreshold = (R - .86602540378443864676*ab)
432 * (R - .86602540378443864676*ab)
435 medThreshold = 0.5 * ab2 + 0.25 * R2
436 - .43301270189221932338 * R * sqrt( 4 * ab2 - R2 );
438 maxThreshold = 0.25 * (R2 - ab2);
447 switch ( _reduction_mode_ ) {
454 for ( i=first; i<=l; i++ ) {
457 if ( mamb > maxThreshold ) {
462 if ( b < mamb ) b = mamb;
469 for ( i=first; i<=l; i++ ) {
472 if ( mamb > maxThreshold ) {
477 if ( b < mamb ) b = mamb;
483 for ( i=first; i<=l; i++ ) {
486 if ( mamb > maxThreshold ) {
491 if ( b < mamb ) b = mamb;
508 for ( i=first; i<=l; i++ ) {
511 if ( mamb > maxThreshold ) {
516 if ( mamb <= minThreshold ) {
521 if ( b < mamb ) b = mamb;
529 for ( i=first; i<=l; i++ ) {
532 if ( mamb > maxThreshold ) {
537 if ( mamb <= minThreshold ) {
542 if ( b < mamb ) b = mamb;
549 for ( i=first; i<=l; i++ ) {
552 if ( mamb > maxThreshold ) {
557 if ( mamb <= minThreshold ) {
562 if ( b < mamb ) b = mamb;
587 if ( squareDiameter <= theSeg->squareDiameter ) {
589 for ( i=first; i<=l; i++ ) {
592 if ( mamb > maxThreshold ) {
597 if ( mamb > minThreshold ) {
599 if ( 3.0 * ( am2 * ab2 - (am2 - mamb)*(am2 - mamb) ) - mamb*mamb < 0 ) {
604 if ( b < mamb ) b = mamb;
614 for ( i=first; i<=l; i++ ) {
617 if ( mamb > maxThreshold ) {
622 if ( mamb > medThreshold ) {
623 if ( b < mamb ) b = mamb;
626 if ( mamb > minThreshold ) {
628 if ( 3.0 * ( am2 * ab2 - (am2 - mamb)*(am2 - mamb) )
629 - (R2 - ab2 - mamb)*(R2 - ab2 - mamb) < 0 ) {
634 if ( b < mamb ) b = mamb;
650 if ( squareDiameter <= theSeg->squareDiameter ) {
652 for ( i=first; i<=l; i++ ) {
655 if ( mamb > maxThreshold ) {
660 if ( mamb > minThreshold ) {
662 if ( 3.0 * ( am2 * ab2 - (am2 - mamb)*(am2 - mamb) ) - mamb*mamb < 0 ) {
667 if ( b < mamb ) b = mamb;
677 for ( i=first; i<=l; i++ ) {
680 if ( mamb > maxThreshold ) {
685 if ( mamb > medThreshold ) {
686 if ( b < mamb ) b = mamb;
689 if ( mamb > minThreshold ) {
691 if ( 3.0 * ( am2 * ab2 - (am2 - mamb)*(am2 - mamb) )
692 - (R2 - ab2 - mamb)*(R2 - ab2 - mamb) < 0 ) {
697 if ( b < mamb ) b = mamb;
711 if ( squareDiameter <= theSeg->squareDiameter ) {
713 for ( i=first; i<=l; i++ ) {
716 if ( mamb > maxThreshold ) {
721 if ( mamb > minThreshold ) {
723 if ( 3.0 * ( am2 * ab2 - (am2 - mamb)*(am2 - mamb) ) - mamb*mamb < 0 ) {
728 if ( b < mamb ) b = mamb;
738 for ( i=first; i<=l; i++ ) {
741 if ( mamb > maxThreshold ) {
746 if ( mamb > medThreshold ) {
747 if ( b < mamb ) b = mamb;
750 if ( mamb > minThreshold ) {
752 if ( 3.0 * ( am2 * ab2 - (am2 - mamb)*(am2 - mamb) )
753 - (R2 - ab2 - mamb)*(R2 - ab2 - mamb) < 0 ) {
758 if ( b < mamb ) b = mamb;
868 const double **theList,
872 const int _reduction_mode_ )
875 int index = first - 1;
876 double diff, maxdiff = 0.0;
879 double threshold = -0.23205080756887729352 * theSeg->
squareDiameter;
881 if ( l < first )
return( index );
884 switch ( _reduction_mode_ ) {
892 for ( i=first; i<=l; i++ ) {
895 if ( maxdiff < diff ) {
904 for ( i=first; i<=l; i++ ) {
907 if ( maxdiff < diff ) {
915 for ( i=first; i<=l; i++ ) {
918 if ( maxdiff < diff ) {
941 for ( i=first; i<=l; i++ ) {
944 if ( diff > maxdiff ) {
948 else if ( diff <= threshold ) {
960 for ( i=first; i<=l; i++ ) {
963 if ( maxdiff < diff ) {
967 else if ( diff <= threshold ) {
978 for ( i=first; i<=l; i++ ) {
981 if ( maxdiff < diff ) {
985 else if ( diff <= threshold ) {
1003 const double **theList1,
1006 const double **theList2,
1024 double d, dprevious;
1032 if ( *first1 < 0 || *last1 < 0 )
return( -1.0 );
1033 if ( *first1 > *last1 )
return( 0.0 );
1034 if ( *first2 < 0 || *last2 < 0 )
return( -1.0 );
1035 if ( *first2 > *last2 )
return( 0.0 );
1036 if ( *first2 > *last2 ) {
1040 if ( index1 < f1 || index1 > l1 )
return( -1.0 );
1104 }
while( theSeg->
squareDiameter > dprevious && f1 <= l1 && f2 <= l2 );
1117 const double **theList,
1128 double d, dprevious;
1136 if ( *first < 0 || *last < 0 )
return( -1.0 );
1137 if ( *first > *last )
return( 0.0 );
1138 if ( index < f || index > l )
return( -1.0 );
1180 const double **theList,
1191 if ( first < 0 || last < 0 )
return( -1.0 );
1192 if ( first > last )
return( 0.0 );
1201 for ( i=f+1; i<=l; i++ ) {
1217 for ( i=f+1; i<=l; i++ ) {
1234 for ( i=f+1; i<=l; i++ ) {
1253 theList[i] = theList[j];
1266 while ( c->
c2 >= _base_ ) {
1270 while ( c->
c2 < 0 ) {
1277 return( (_base_ / (
double)i ) * c->
c1 + c->
c2 / (
double)i );
1284 void _InitScalarProductCounter()
1288 static void _IncScalarProductCounter()
1292 double _GetScalarProductAverage(
int n )
1306 register double d = 0.0;
1308 for ( i=0; i<dim; i++ ) {
1314 _IncScalarProductCounter();
1328 _IncScalarProductCounter();
1331 return( (b[0]-a[0])*(b[0]-a[0]) +
1332 (b[1]-a[1])*(b[1]-a[1]) +
1333 (b[2]-a[2])*(b[2]-a[2]) );
1341 _IncScalarProductCounter();
1344 return( (b[0]-a[0])*(b[0]-a[0]) +
1345 (b[1]-a[1])*(b[1]-a[1]) );
1355 const double *c,
const double *d,
const int dim )
1358 register double scalar = 0.0;
1359 register double ab, cd;
1360 for ( i=0; i<dim; i++ ) {
1367 _IncScalarProductCounter();
1376 const double *c,
const double *d )
1380 _IncScalarProductCounter();
1383 return( (b[0]-a[0])*(d[0]-c[0]) +
1384 (b[1]-a[1])*(d[1]-c[1]) +
1385 (b[2]-a[2])*(d[2]-c[2]) );
1389 const double *c,
const double *d )
1393 _IncScalarProductCounter();
1396 return( (b[0]-a[0])*(d[0]-c[0]) +
1397 (b[1]-a[1])*(d[1]-c[1]) );
1408 for ( i=first; i<=last; i++ ) {
1409 if ( theList[i][0]-e < x0 && theList[i][0]+e > x0 &&
1410 theList[i][1]-e < x1 && theList[i][1]+e > x1 ) {
1414 fprintf( stderr,
"found again at #%d\n", i );
1443 const double **theList,
1459 for ( i=first; i<=last-1; i++ )
1460 for ( j=i+1; j<=last; j++ ) {
1476 for ( i=first; i<=last-1; i++ )
1477 for ( j=i+1; j<=last; j++ ) {
1491 for ( i=first; i<=last-1; i++ )
1492 for ( j=i+1; j<=last; j++ ) {
1514 const double **theList1,
1517 const double **theList2,
1531 if ( index1 != NULL && index2 != NULL ) {
1540 for ( i=first1; i<=last1; i++ )
1541 for ( j=first2; j<=last2; j++ ) {
1547 if ( index1 != NULL && index2 != NULL ) {
1561 for ( i=first1; i<=last1; i++ )
1562 for ( j=first2; j<=last2; j++ ) {
1568 if ( index1 != NULL && index2 != NULL ) {
1580 for ( i=first1; i<=last1; i++ )
1581 for ( j=first2; j<=last2; j++ ) {
1587 if ( index1 != NULL && index2 != NULL ) {
APPROXMVBB_EXPORT int _FarthestPointFromSphere(TypeSegment *theSeg, double const **theList, const int first, int *last, const int dim, const int _reduction_mode_)
These are some container definitions.
double const * extremity2
APPROXMVBB_EXPORT double _MaximalSegmentInOneList(TypeSegment *theSeg, const int index, double const **theList, int *first, int *last, const int dim)
APPROXMVBB_EXPORT double _SquareDistance3D(double const *a, double const *b)
APPROXMVBB_EXPORT void _SwapPoints(double const **theList, const int i, const int j)
APPROXMVBB_EXPORT int _FindPointInList(double const **theList, const int first, const int last, double x0, double x1)
APPROXMVBB_EXPORT double _QuadraticDiameterInTwoLists(TypeSegment *theDiam, int *index1, int *index2, double const **theList1, const int first1, const int last1, double const **theList2, const int first2, const int last2, const int dim)
APPROXMVBB_EXPORT double _QuadraticDiameterInOneList(TypeSegment *theDiam, double const **theList, const int first, const int last, const int dim)
APPROXMVBB_EXPORT double _MaximalSegmentInTwoLists(TypeSegment *theSeg, const int index1, double const **theList1, int *first1, int *last1, double const **theList2, int *first2, int *last2, int dim)
APPROXMVBB_EXPORT int _LastPointOutsideSphereWithDiameter(TypeSegment *theSeg, double constsquareDiameter, double const **theList, const int first, int *last, const int dim, const int _reduction_mode_)
APPROXMVBB_EXPORT double _ScalarProduct(double const *a, double const *b, double const *c, double const *d, const int dim)
APPROXMVBB_EXPORT double _GetCounterAverage(TypeCounter *c, const int i)
APPROXMVBB_EXPORT void _InitCounter(TypeCounter *c)
APPROXMVBB_EXPORT double _SquareDistance2D(double const *a, double const *b)
APPROXMVBB_EXPORT double _ScalarProduct2D(double const *a, double const *b, double const *c, double const *d)
APPROXMVBB_EXPORT double _MaximalDistanceFromPoint(int *index, double const *ref, double const **theList, const int first, const int last, const int dim)
double const * extremity1
APPROXMVBB_EXPORT void _AddToCounter(TypeCounter *c, const int i)
APPROXMVBB_EXPORT int _LastPointOutsideSphereAndBoundWithDiameter(TypeSegment *theSeg, double constsquareDiameter, double const **theList, const int first, int *last, const int dim, const int _reduction_mode_, double *bound)
APPROXMVBB_EXPORT double _SquareDistance(double const *a, double const *b, const int dim)
APPROXMVBB_EXPORT double _ScalarProduct3D(double const *a, double const *b, double const *c, double const *d)