summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-08-23 14:03:21 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-05-19 16:50:31 +0100
commit5a6ed660ec74e445a827c7aa41e4793c64a46271 (patch)
treede8dedebb69847d3e96c371e0c19554051364470 /include
parent2d55b2e5ae0d4f1a05e1ce5b20a7b342d6ea8b1d (diff)
Resolves: #i120596# Optimized grid primitive
added some tooling to basegfx (cherry picked from commit 97fa4faaa0b09724cf98dbf22390b283ba57b41c) Conflicts: basegfx/inc/basegfx/numeric/ftools.hxx Change-Id: Ib15c43cf4d5b50605ec596dab498e3a678f3734a
Diffstat (limited to 'include')
-rw-r--r--include/basegfx/numeric/ftools.hxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/basegfx/numeric/ftools.hxx b/include/basegfx/numeric/ftools.hxx
index 70dcabe1a190..75e24b0d8574 100644
--- a/include/basegfx/numeric/ftools.hxx
+++ b/include/basegfx/numeric/ftools.hxx
@@ -136,6 +136,36 @@ namespace basegfx
return v / M_PI_2 * 90.0;
}
+ /** Snap v to nearest multiple of fStep, from negative and
+ positive side.
+
+ Examples:
+
+ snapToNearestMultiple(-0.1, 0.5) = 0.0
+ snapToNearestMultiple(0.1, 0.5) = 0.0
+ snapToNearestMultiple(0.25, 0.5) = 0.0
+ snapToNearestMultiple(0.26, 0.5) = 0.5
+ */
+ double snapToNearestMultiple(double v, const double fStep);
+
+ /** Snap v to the range [0.0 .. fWidth] using modulo
+ */
+ double snapToZeroRange(double v, double fWidth);
+
+ /** Snap v to the range [fLow .. fHigh] using modulo
+ */
+ double snapToRange(double v, double fLow, double fHigh);
+
+ /** return fValue with the sign of fSignCarrier, thus evtl. changed
+ */
+ inline double copySign(double fValue, double fSignCarrier)
+ {
+#ifdef WNT
+ return _copysign(fValue, fSignCarrier);
+#else
+ return copysign(fValue, fSignCarrier);
+#endif
+ }
class BASEGFX_DLLPUBLIC fTools
{