Arithmetic including a tolerance. More...
#include <qwt_scale_engine.h>
Static Public Member Functions | |
static int | compareEps (double value1, double value2, double intervalSize) |
Compare 2 values, relative to an interval. | |
static double | ceilEps (double value, double intervalSize) |
static double | floorEps (double value, double intervalSize) |
static double | divideEps (double interval, double steps) |
Divide an interval into steps. | |
static double | ceil125 (double x) |
static double | floor125 (double x) |
Find the largest value out of {1,2,5}*10^n with an integer number n which is smaller than or equal to x. |
Arithmetic including a tolerance.
Definition at line 22 of file qwt_scale_engine.h.
double QwtScaleArithmetic::ceil125 | ( | double | x ) | [static] |
Find the smallest value out of {1,2,5}*10^n with an integer number n which is greater than or equal to x
x | Input value |
Definition at line 98 of file qwt_scale_engine.cpp.
References QuadProgPP::pow(), and sign().
Referenced by QwtScaleEngine::divideInterval().
{ if (x == 0.0) return 0.0; const double sign = (x > 0) ? 1.0 : -1.0; const double lx = log10(fabs(x)); const double p10 = floor(lx); double fr = pow(10.0, lx - p10); if (fr <=1.0) fr = 1.0; else if (fr <= 2.0) fr = 2.0; else if (fr <= 5.0) fr = 5.0; else fr = 10.0; return sign * fr * pow(10.0, p10); }
double QwtScaleArithmetic::ceilEps | ( | double | value, |
double | intervalSize | ||
) | [static] |
Ceil a value, relative to an interval
value | Value to ceil |
intervalSize | Interval size |
Definition at line 50 of file qwt_scale_engine.cpp.
References _eps.
Referenced by QwtLinearScaleEngine::align().
{ const double eps = _eps * intervalSize; value = (value - eps) / intervalSize; return ceil(value) * intervalSize; }
int QwtScaleArithmetic::compareEps | ( | double | value1, |
double | value2, | ||
double | intervalSize | ||
) | [static] |
Compare 2 values, relative to an interval.
Values are "equal", when :
value1 | First value to compare |
value2 | Second value to compare |
intervalSize | interval size |
Definition at line 28 of file qwt_scale_engine.cpp.
Referenced by QwtScaleEngine::contains().
double QwtScaleArithmetic::divideEps | ( | double | intervalSize, |
double | numSteps | ||
) | [static] |
Divide an interval into steps.
intervalSize | Interval size |
numSteps | Number of steps |
Definition at line 84 of file qwt_scale_engine.cpp.
References _eps.
Referenced by QwtScaleEngine::divideInterval().
{ if ( numSteps == 0.0 || intervalSize == 0.0 ) return 0.0; return (intervalSize - (_eps * intervalSize)) / numSteps; }
double QwtScaleArithmetic::floor125 | ( | double | x ) | [static] |
Find the largest value out of {1,2,5}*10^n with an integer number n which is smaller than or equal to x.
x | Input value |
Definition at line 126 of file qwt_scale_engine.cpp.
References QuadProgPP::pow(), and sign().
double QwtScaleArithmetic::floorEps | ( | double | value, |
double | intervalSize | ||
) | [static] |
Floor a value, relative to an interval
value | Value to floor |
intervalSize | Interval size |
Definition at line 67 of file qwt_scale_engine.cpp.
References _eps.
Referenced by QwtLinearScaleEngine::align().
{ const double eps = _eps * intervalSize; value = (value + eps) / intervalSize; return floor(value) * intervalSize; }