summaryrefslogtreecommitdiff
path: root/basegfx/source/tuple
diff options
context:
space:
mode:
authorThorsten Behrens <thb@openoffice.org>2004-02-25 08:54:11 +0000
committerThorsten Behrens <thb@openoffice.org>2004-02-25 08:54:11 +0000
commitcd2ca2e0d127c6ac7a6baaefee6e2088c1df098f (patch)
treefc749563189aff1c4a33266f076690aab6f9b2b8 /basegfx/source/tuple
parentea8c622450a59641b2f7af9809182fc490f89672 (diff)
#110496# Made B2ITuple convertible to B2DTuple. Completed filter list
Diffstat (limited to 'basegfx/source/tuple')
-rw-r--r--basegfx/source/tuple/b2ituple.cxx115
1 files changed, 113 insertions, 2 deletions
diff --git a/basegfx/source/tuple/b2ituple.cxx b/basegfx/source/tuple/b2ituple.cxx
index 24bb4bc1d160..4211d66db6c6 100644
--- a/basegfx/source/tuple/b2ituple.cxx
+++ b/basegfx/source/tuple/b2ituple.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2ituple.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: thb $ $Date: 2004-01-16 10:37:24 $
+ * last change: $Author: thb $ $Date: 2004-02-25 09:54:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,12 +62,123 @@
#ifndef _BGFX_TUPLE_B2ITUPLE_HXX
#include <basegfx/tuple/b2ituple.hxx>
#endif
+#ifndef _BGFX_TUPLE_B2DTUPLE_HXX
+#include <basegfx/tuple/b2dtuple.hxx>
+#endif
namespace basegfx
{
// initialize static member
::basegfx::B2ITuple B2ITuple::maEmptyTuple(0, 0);
+ // external operators
+ //////////////////////////////////////////////////////////////////////////
+
+ B2ITuple minimum(const B2ITuple& rTupA, const B2ITuple& rTupB)
+ {
+ B2ITuple aMin(
+ (rTupB.getX() < rTupA.getX()) ? rTupB.getX() : rTupA.getX(),
+ (rTupB.getY() < rTupA.getY()) ? rTupB.getY() : rTupA.getY());
+ return aMin;
+ }
+
+ B2ITuple maximum(const B2ITuple& rTupA, const B2ITuple& rTupB)
+ {
+ B2ITuple aMax(
+ (rTupB.getX() > rTupA.getX()) ? rTupB.getX() : rTupA.getX(),
+ (rTupB.getY() > rTupA.getY()) ? rTupB.getY() : rTupA.getY());
+ return aMax;
+ }
+
+ B2ITuple absolute(const B2ITuple& rTup)
+ {
+ B2ITuple aAbs(
+ (0 > rTup.getX()) ? -rTup.getX() : rTup.getX(),
+ (0 > rTup.getY()) ? -rTup.getY() : rTup.getY());
+ return aAbs;
+ }
+
+ B2DTuple interpolate(const B2ITuple& rOld1, const B2ITuple& rOld2, double t)
+ {
+ B2DTuple aInt(
+ ((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
+ ((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY());
+ return aInt;
+ }
+
+ B2DTuple average(const B2ITuple& rOld1, const B2ITuple& rOld2)
+ {
+ B2DTuple aAvg(
+ (rOld1.getX() + rOld2.getX()) * 0.5,
+ (rOld1.getY() + rOld2.getY()) * 0.5);
+ return aAvg;
+ }
+
+ B2DTuple average(const B2ITuple& rOld1, const B2ITuple& rOld2, const B2ITuple& rOld3)
+ {
+ B2DTuple aAvg(
+ (rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0),
+ (rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0));
+ return aAvg;
+ }
+
+ B2ITuple operator+(const B2ITuple& rTupA, const B2ITuple& rTupB)
+ {
+ B2ITuple aSum(rTupA);
+ aSum += rTupB;
+ return aSum;
+ }
+
+ B2ITuple operator-(const B2ITuple& rTupA, const B2ITuple& rTupB)
+ {
+ B2ITuple aSub(rTupA);
+ aSub -= rTupB;
+ return aSub;
+ }
+
+ B2ITuple operator/(const B2ITuple& rTupA, const B2ITuple& rTupB)
+ {
+ B2ITuple aDiv(rTupA);
+ aDiv /= rTupB;
+ return aDiv;
+ }
+
+ B2ITuple operator*(const B2ITuple& rTupA, const B2ITuple& rTupB)
+ {
+ B2ITuple aMul(rTupA);
+ aMul *= rTupB;
+ return aMul;
+ }
+
+ B2ITuple operator*(const B2ITuple& rTup, sal_Int32 t)
+ {
+ B2ITuple aNew(rTup);
+ aNew *= t;
+ return aNew;
+ }
+
+ B2ITuple operator*(sal_Int32 t, const B2ITuple& rTup)
+ {
+ B2ITuple aNew(rTup);
+ aNew *= t;
+ return aNew;
+ }
+
+ B2ITuple operator/(const B2ITuple& rTup, sal_Int32 t)
+ {
+ B2ITuple aNew(rTup);
+ aNew /= t;
+ return aNew;
+ }
+
+ B2ITuple operator/(sal_Int32 t, const B2ITuple& rTup)
+ {
+ B2ITuple aNew(t, t);
+ B2ITuple aTmp(rTup);
+ aNew /= aTmp;
+ return aNew;
+ }
+
} // end of namespace basegfx
// eof