38 inline sal_Int32
fround(
double fVal )
42 if (fVal >= std::numeric_limits<sal_Int32>::max() - .5)
43 return std::numeric_limits<sal_Int32>::max();
44 return static_cast<sal_Int32
>(fVal + .5);
46 if (fVal <= std::numeric_limits<sal_Int32>::min() + .5)
47 return std::numeric_limits<sal_Int32>::min();
48 return static_cast<sal_Int32
>(fVal - .5);
57 return fVal > 0.0 ?
static_cast<sal_Int64
>( fVal + .5 ) : -
static_cast<sal_Int64
>( -fVal + .5 );
75 return std::min(fVal, -0.00001);
77 return std::max(fVal, 0.00001);
82 template <
int DegMultiple = 1>
constexpr double deg2rad(
double v )
86 return v / (90.0 * DegMultiple) * M_PI_2;
91 template <
int DegMultiple = 1>
constexpr double rad2deg(
double v )
95 return v / M_PI_2 * (90.0 * DegMultiple);
116 double snapToRange(
double v,
double fLow,
double fHigh);
120 inline double copySign(
double fValue,
double fSignCarrier)
123 return _copysign(fValue, fSignCarrier);
125 return copysign(fValue, fSignCarrier);
155 template <
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
162 template <
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
163 inline bool equalZero(
const T& rfVal,
const T& rfSmallValue)
165 return (fabs(rfVal) <= rfSmallValue);
168 template <
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
169 inline bool equal(T
const& rfValA, T
const& rfValB)
172 return rtl_math_approxEqual(rfValA, rfValB);
175 template <
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
176 inline bool equal(
const T& rfValA,
const T& rfValB,
const T& rfSmallValue)
178 return (fabs(rfValA - rfValB) <= rfSmallValue);
181 template <
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
182 inline bool less(
const T& rfValA,
const T& rfValB)
184 return (rfValA < rfValB && !
equal(rfValA, rfValB));
187 template <
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
190 return (rfValA < rfValB ||
equal(rfValA, rfValB));
193 template <
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
194 inline bool more(
const T& rfValA,
const T& rfValB)
196 return (rfValA > rfValB && !
equal(rfValA, rfValB));
199 template <
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
202 return (rfValA > rfValB ||
equal(rfValA, rfValB));
205 template <
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
208 return (rfValA > rfValB && rfValA < rfValC) ||
equal(rfValA, rfValB) ||
equal(rfValA, rfValC);
#define BASEGFX_DLLPUBLIC
double snapToNearestMultiple(double v, const double fStep)
Snap v to nearest multiple of fStep, from negative and positive side.
double normalizeToRange(double v, const double fRange)
RotateFlyFrame3: Normalize to range defined by [0.0 ... fRange[, independent if v is positive or nega...
double pruneScaleValue(double fVal)
Prune a small epsilon range around zero.
constexpr double rad2deg(double v)
Convert value radians to degrees.
double copySign(double fValue, double fSignCarrier)
return fValue with the sign of fSignCarrier, thus evtl.
B2IRange fround(const B2DRange &rRange)
Round double to nearest integer for 2D range.
double snapToRange(double v, double fLow, double fHigh)
Snap v to the range [fLow .
constexpr double deg2rad(double v)
Convert value from degrees to radians.
double snapToZeroRange(double v, double fWidth)
Snap v to the range [0.0 .
sal_Int64 fround64(double fVal)
Round double to nearest integer.