Searches for maxima across a grid in concentric way. More...
#include <ConcentricSearch.h>
Public Member Functions | |
ConcentricSearch () | |
double | dr () const |
Angle | maxAngle () const |
Angle | maxAngle (double radius) const |
double | maximum (QAtomicInt *terminate=0) |
double | maxRadius () const |
double | maxX () const |
double | maxY () const |
double | r0 () const |
void | setCenter (double x, double y) |
void | setGrid (double minR, double maxR, double dR) |
void | setMaximumRadius (double maxR) |
void | setNoiseLevel (double nl) |
~ConcentricSearch () |
Searches for maxima across a grid in concentric way.
The search is made along grid axes, not really along a perfect circle.
maxX(), maxY() and maxRadius() caracterize the exact position the last maximum. Refinement precision of set as 0.001 times the step dr.
maximum() starts the search. It can be called several times until returning 0;
double QGpCoreTools::ConcentricSearch::dr | ( | ) | const [inline] |
{return _dr;}
Angle QGpCoreTools::ConcentricSearch::maxAngle | ( | ) | const [inline] |
{return Angle(_maxX-_x, _maxY-_y);}
Angle QGpCoreTools::ConcentricSearch::maxAngle | ( | double | radius | ) | const [inline] |
{return Angle(_maxX-_x, _maxY-_y, radius);}
double QGpCoreTools::ConcentricSearch::maximum | ( | QAtomicInt * | terminate = 0 | ) |
Searches for the next maximum starting at current r0. After each turn, r0 is incremented by the step dr. It returns the value reached by the found maximum or 0.0, if no maximum has been found. It can be called several times while not returning 0.0.
terminate is an optional flag to interrupt current search.
References TRACE.
{ TRACE; while(_r0<=_rMax) { if(terminate && terminate->testAndSetOrdered(true,true)) { return 0.0; } switch (_segment) { case Top: if(scanX(_x-_r0,_x+_r0,_y-_r0)) return _maxValue; _segment=Bottom; _pos=_x-_r0; break; case Bottom: if(scanX(_x-_r0,_x+_r0,_y+_r0)) return _maxValue; _segment=Left; _pos=_y-_r0; break; case Left: if(scanY(_y-_r0,_y+_r0,_x-_r0)) return _maxValue; _segment=Right; _pos=_y-_r0; break; case Right: if(scanY(_y-_r0,_y+_r0,_x+_r0)) return _maxValue; _segment=Top; _pos=_x-_r0; break; } _r0Mutex.lock(); _r0+=_dr; _r0Mutex.unlock(); } return 0.0; }
double QGpCoreTools::ConcentricSearch::maxRadius | ( | ) | const |
Return the maxium radius ever reached during refinements.
References QGpCoreTools::sqrt(), and TRACE.
{ TRACE; double dx=_maxX-_x; double dy=_maxY-_y; return ::sqrt(dx*dx+dy*dy); }
double QGpCoreTools::ConcentricSearch::maxX | ( | ) | const [inline] |
{return _maxX;}
double QGpCoreTools::ConcentricSearch::maxY | ( | ) | const [inline] |
{return _maxY;}
double QGpCoreTools::ConcentricSearch::r0 | ( | ) | const |
References TRACE.
Referenced by ArrayCore::KmaxSolver::kmax().
{ TRACE; QMutexLocker ml(&_r0Mutex); return _r0; }
void QGpCoreTools::ConcentricSearch::setCenter | ( | double | x, |
double | y | ||
) | [inline] |
Referenced by ArrayCore::KmaxSolver::KmaxSolver().
{_x=x; _y=y;}
void QGpCoreTools::ConcentricSearch::setGrid | ( | double | minR, |
double | maxR, | ||
double | dR | ||
) |
minR is the starting radius. dR is the general step (either in radius or along the circle). maxR is the maximum radius to cover.
References TRACE.
Referenced by ArrayCore::KmaxSolver::KmaxSolver().
{ TRACE; _r0=minR; _rMax=maxR; _pos=_x-_r0; _dr=dR; ASSERT(_r0>2.0*_dr); _precision=_dr*0.001; }
void QGpCoreTools::ConcentricSearch::setMaximumRadius | ( | double | maxR | ) | [inline] |
{_rMax=maxR;}
void QGpCoreTools::ConcentricSearch::setNoiseLevel | ( | double | nl | ) | [inline] |
Referenced by ArrayCore::KmaxSolver::KmaxSolver().
{_noiseLevel=nl;}