Related: #i120604# corrected 3d gradients
adapted basegfx to be smarter in some areas (cherry picked from commit 888e64505474808166c29ada24178cc3e58d6c18) Conflicts: basegfx/inc/basegfx/pixel/bpixel.hxx basegfx/inc/basegfx/point/b2dhompoint.hxx basegfx/inc/basegfx/point/b3dhompoint.hxx basegfx/inc/basegfx/raster/rasterconvert3d.hxx basegfx/inc/basegfx/tuple/b2dtuple.hxx basegfx/inc/basegfx/tuple/b2i64tuple.hxx basegfx/inc/basegfx/tuple/b2ituple.hxx basegfx/inc/basegfx/tuple/b3dtuple.hxx basegfx/inc/basegfx/tuple/b3i64tuple.hxx basegfx/inc/basegfx/tuple/b3ituple.hxx basegfx/source/point/b2dhompoint.cxx basegfx/source/tuple/b2ituple.cxx Change-Id: Id92864093dd40d34bd20b130cc3b405a7b8f9d91
This commit is contained in:
committed by
Caolán McNamara
parent
5e39bc0937
commit
59db4be207
@@ -355,19 +355,20 @@ namespace basegfx
|
||||
{
|
||||
const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV);
|
||||
|
||||
if(aCoor.getX() < 0.0 || aCoor.getX() > 1.0)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
// Ignore Y, this is not needed at all for Y-Oriented gradients
|
||||
// if(aCoor.getX() < 0.0 || aCoor.getX() > 1.0)
|
||||
// {
|
||||
// return 0.0;
|
||||
// }
|
||||
|
||||
if(aCoor.getY() <= 0.0)
|
||||
{
|
||||
return 0.0;
|
||||
return 0.0; // start value for inside
|
||||
}
|
||||
|
||||
if(aCoor.getY() >= 1.0)
|
||||
{
|
||||
return 1.0;
|
||||
return 1.0; // end value for outside
|
||||
}
|
||||
|
||||
const sal_uInt32 nSteps(rGradInfo.getSteps());
|
||||
@@ -384,16 +385,17 @@ namespace basegfx
|
||||
{
|
||||
const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV);
|
||||
|
||||
if(aCoor.getX() < 0.0 || aCoor.getX() > 1.0)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
// Ignore Y, this is not needed at all for Y-Oriented gradients
|
||||
//if(aCoor.getX() < 0.0 || aCoor.getX() > 1.0)
|
||||
//{
|
||||
// return 0.0;
|
||||
//}
|
||||
|
||||
const double fAbsY(fabs(aCoor.getY()));
|
||||
|
||||
if(fAbsY >= 1.0)
|
||||
{
|
||||
return 0.0;
|
||||
return 1.0; // use end value when outside in Y
|
||||
}
|
||||
|
||||
const sal_uInt32 nSteps(rGradInfo.getSteps());
|
||||
|
@@ -23,68 +23,4 @@
|
||||
|
||||
namespace { struct EmptyTuple : public rtl::Static<basegfx::B2ITuple, EmptyTuple> {}; }
|
||||
|
||||
namespace basegfx
|
||||
{
|
||||
// external operators
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -157,7 +157,7 @@ namespace drawinglayer
|
||||
{
|
||||
const double fScaler(basegfx::tools::getLinearGradientAlpha(rUV, maGradientInfo));
|
||||
|
||||
rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler);
|
||||
rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
|
||||
}
|
||||
} // end of namespace texture
|
||||
} // end of namespace drawinglayer
|
||||
@@ -220,7 +220,7 @@ namespace drawinglayer
|
||||
{
|
||||
const double fScaler(basegfx::tools::getAxialGradientAlpha(rUV, maGradientInfo));
|
||||
|
||||
rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler);
|
||||
rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
|
||||
}
|
||||
} // end of namespace texture
|
||||
} // end of namespace drawinglayer
|
||||
@@ -277,7 +277,7 @@ namespace drawinglayer
|
||||
{
|
||||
const double fScaler(basegfx::tools::getRadialGradientAlpha(rUV, maGradientInfo));
|
||||
|
||||
rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler);
|
||||
rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
|
||||
}
|
||||
} // end of namespace texture
|
||||
} // end of namespace drawinglayer
|
||||
@@ -354,7 +354,7 @@ namespace drawinglayer
|
||||
{
|
||||
const double fScaler(basegfx::tools::getEllipticalGradientAlpha(rUV, maGradientInfo));
|
||||
|
||||
rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler);
|
||||
rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
|
||||
}
|
||||
} // end of namespace texture
|
||||
} // end of namespace drawinglayer
|
||||
@@ -413,7 +413,7 @@ namespace drawinglayer
|
||||
{
|
||||
const double fScaler(basegfx::tools::getSquareGradientAlpha(rUV, maGradientInfo));
|
||||
|
||||
rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler);
|
||||
rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
|
||||
}
|
||||
} // end of namespace texture
|
||||
} // end of namespace drawinglayer
|
||||
@@ -490,7 +490,7 @@ namespace drawinglayer
|
||||
{
|
||||
const double fScaler(basegfx::tools::getRectangularGradientAlpha(rUV, maGradientInfo));
|
||||
|
||||
rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler);
|
||||
rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
|
||||
}
|
||||
} // end of namespace texture
|
||||
} // end of namespace drawinglayer
|
||||
|
@@ -135,22 +135,20 @@ namespace basegfx
|
||||
|
||||
inline BPixel minimum(const BPixel& rTupA, const BPixel& rTupB)
|
||||
{
|
||||
BPixel aMin(
|
||||
(rTupB.getRed() < rTupA.getRed()) ? rTupB.getRed() : rTupA.getRed(),
|
||||
(rTupB.getGreen() < rTupA.getGreen()) ? rTupB.getGreen() : rTupA.getGreen(),
|
||||
(rTupB.getBlue() < rTupA.getBlue()) ? rTupB.getBlue() : rTupA.getBlue(),
|
||||
(rTupB.getOpacity() < rTupA.getOpacity()) ? rTupB.getOpacity() : rTupA.getOpacity());
|
||||
return aMin;
|
||||
return BPixel(
|
||||
std::min(rTupB.getRed(), rTupA.getRed()),
|
||||
std::min(rTupB.getGreen(), rTupA.getGreen()),
|
||||
std::min(rTupB.getBlue(), rTupA.getBlue()),
|
||||
std::min(rTupB.getOpacity(), rTupA.getOpacity()));
|
||||
}
|
||||
|
||||
inline BPixel maximum(const BPixel& rTupA, const BPixel& rTupB)
|
||||
{
|
||||
BPixel aMax(
|
||||
(rTupB.getRed() > rTupA.getRed()) ? rTupB.getRed() : rTupA.getRed(),
|
||||
(rTupB.getGreen() > rTupA.getGreen()) ? rTupB.getGreen() : rTupA.getGreen(),
|
||||
(rTupB.getBlue() > rTupA.getBlue()) ? rTupB.getBlue() : rTupA.getBlue(),
|
||||
(rTupB.getOpacity() > rTupA.getOpacity()) ? rTupB.getOpacity() : rTupA.getOpacity());
|
||||
return aMax;
|
||||
return BPixel(
|
||||
std::max(rTupB.getRed(), rTupA.getRed()),
|
||||
std::max(rTupB.getGreen(), rTupA.getGreen()),
|
||||
std::max(rTupB.getBlue(), rTupA.getBlue()),
|
||||
std::max(rTupB.getOpacity(), rTupA.getOpacity()));
|
||||
}
|
||||
|
||||
inline BPixel interpolate(const BPixel& rOld1, const BPixel& rOld2, double t)
|
||||
@@ -171,6 +169,7 @@ namespace basegfx
|
||||
{
|
||||
const sal_uInt32 nFactor(fround(256.0 * t));
|
||||
const sal_uInt32 nNegFac(256L - nFactor);
|
||||
|
||||
return BPixel(
|
||||
(sal_uInt8)(((sal_uInt32)rOld1.getRed() * nNegFac + (sal_uInt32)rOld2.getRed() * nFactor) >> 8L),
|
||||
(sal_uInt8)(((sal_uInt32)rOld1.getGreen() * nNegFac + (sal_uInt32)rOld2.getGreen() * nFactor) >> 8L),
|
||||
@@ -181,34 +180,20 @@ namespace basegfx
|
||||
|
||||
inline BPixel average(const BPixel& rOld1, const BPixel& rOld2)
|
||||
{
|
||||
if(rOld1 == rOld2)
|
||||
{
|
||||
return rOld1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return BPixel(
|
||||
(sal_uInt8)(((sal_uInt32)rOld1.getRed() + (sal_uInt32)rOld2.getRed()) >> 1L),
|
||||
(sal_uInt8)(((sal_uInt32)rOld1.getGreen() + (sal_uInt32)rOld2.getGreen()) >> 1L),
|
||||
(sal_uInt8)(((sal_uInt32)rOld1.getBlue() + (sal_uInt32)rOld2.getBlue()) >> 1L),
|
||||
(sal_uInt8)(((sal_uInt32)rOld1.getOpacity() + (sal_uInt32)rOld2.getOpacity()) >> 1L));
|
||||
}
|
||||
return BPixel(
|
||||
rOld1.getRed() == rOld2.getRed() ? rOld1.getRed() : (sal_uInt8)(((sal_uInt32)rOld1.getRed() + (sal_uInt32)rOld2.getRed()) >> 1L),
|
||||
rOld1.getGreen() == rOld2.getGreen() ? rOld1.getGreen() : (sal_uInt8)(((sal_uInt32)rOld1.getGreen() + (sal_uInt32)rOld2.getGreen()) >> 1L),
|
||||
rOld1.getBlue() == rOld2.getBlue() ? rOld1.getBlue() : (sal_uInt8)(((sal_uInt32)rOld1.getBlue() + (sal_uInt32)rOld2.getBlue()) >> 1L),
|
||||
rOld1.getOpacity() == rOld2.getOpacity() ? rOld1.getOpacity() : (sal_uInt8)(((sal_uInt32)rOld1.getOpacity() + (sal_uInt32)rOld2.getOpacity()) >> 1L));
|
||||
}
|
||||
|
||||
inline BPixel average(const BPixel& rOld1, const BPixel& rOld2, const BPixel& rOld3)
|
||||
{
|
||||
if(rOld1 == rOld2 && rOld2 == rOld3)
|
||||
{
|
||||
return rOld1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return BPixel(
|
||||
(sal_uInt8)(((sal_uInt32)rOld1.getRed() + (sal_uInt32)rOld2.getRed() + (sal_uInt32)rOld3.getRed()) / 3L),
|
||||
(sal_uInt8)(((sal_uInt32)rOld1.getGreen() + (sal_uInt32)rOld2.getGreen() + (sal_uInt32)rOld3.getGreen()) / 3L),
|
||||
(sal_uInt8)(((sal_uInt32)rOld1.getBlue() + (sal_uInt32)rOld2.getBlue() + (sal_uInt32)rOld3.getBlue()) / 3L),
|
||||
(sal_uInt8)(((sal_uInt32)rOld1.getOpacity() + (sal_uInt32)rOld2.getOpacity() + (sal_uInt32)rOld3.getOpacity()) / 3L));
|
||||
}
|
||||
return BPixel(
|
||||
(rOld1.getRed() == rOld2.getRed() && rOld2.getRed() == rOld3.getRed()) ? rOld1.getRed() : (sal_uInt8)(((sal_uInt32)rOld1.getRed() + (sal_uInt32)rOld2.getRed() + (sal_uInt32)rOld3.getRed()) / 3L),
|
||||
(rOld1.getGreen() == rOld2.getGreen() && rOld2.getGreen() == rOld3.getGreen()) ? rOld1.getGreen() : (sal_uInt8)(((sal_uInt32)rOld1.getGreen() + (sal_uInt32)rOld2.getGreen() + (sal_uInt32)rOld3.getGreen()) / 3L),
|
||||
(rOld1.getBlue() == rOld2.getBlue() && rOld2.getBlue() == rOld3.getBlue()) ? rOld1.getBlue() : (sal_uInt8)(((sal_uInt32)rOld1.getBlue() + (sal_uInt32)rOld2.getBlue() + (sal_uInt32)rOld3.getBlue()) / 3L),
|
||||
(rOld1.getOpacity() == rOld2.getOpacity() && rOld2.getOpacity() == rOld3.getOpacity()) ? rOld1.getOpacity() : (sal_uInt8)(((sal_uInt32)rOld1.getOpacity() + (sal_uInt32)rOld2.getOpacity() + (sal_uInt32)rOld3.getOpacity()) / 3L));
|
||||
}
|
||||
} // end of namespace basegfx
|
||||
|
||||
|
@@ -141,42 +141,152 @@ namespace basegfx
|
||||
protected:
|
||||
sal_uInt32 addColorInterpolator(const BColor& rA, const BColor& rB, double fInvYDelta)
|
||||
{
|
||||
B3DVector aDelta(rB.getRed() - rA.getRed(), rB.getGreen() - rA.getGreen(), rB.getBlue() - rA.getBlue());
|
||||
aDelta *= fInvYDelta;
|
||||
maColorInterpolators.push_back(ip_triple(rA.getRed(), aDelta.getX(), rA.getGreen(), aDelta.getY(), rA.getBlue(), aDelta.getZ()));
|
||||
return (maColorInterpolators.size() - 1L);
|
||||
double aDeltaRed(rB.getRed() - rA.getRed());
|
||||
|
||||
if(fTools::equalZero(aDeltaRed))
|
||||
{
|
||||
aDeltaRed = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
aDeltaRed *= fInvYDelta;
|
||||
}
|
||||
|
||||
double aDeltaGreen(rB.getGreen() - rA.getGreen());
|
||||
|
||||
if(fTools::equalZero(aDeltaGreen))
|
||||
{
|
||||
aDeltaGreen = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
aDeltaGreen *= fInvYDelta;
|
||||
}
|
||||
|
||||
double aDeltaBlue(rB.getBlue() - rA.getBlue());
|
||||
|
||||
if(fTools::equalZero(aDeltaBlue))
|
||||
{
|
||||
aDeltaBlue = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
aDeltaBlue *= fInvYDelta;
|
||||
}
|
||||
|
||||
maColorInterpolators.push_back(
|
||||
ip_triple(
|
||||
rA.getRed(), aDeltaRed,
|
||||
rA.getGreen(), aDeltaGreen,
|
||||
rA.getBlue(), aDeltaBlue));
|
||||
|
||||
return (maColorInterpolators.size() - 1);
|
||||
}
|
||||
|
||||
sal_uInt32 addNormalInterpolator(const B3DVector& rA, const B3DVector& rB, double fInvYDelta)
|
||||
{
|
||||
B3DVector aDelta(rB.getX() - rA.getX(), rB.getY() - rA.getY(), rB.getZ() - rA.getZ());
|
||||
aDelta *= fInvYDelta;
|
||||
maNormalInterpolators.push_back(ip_triple(rA.getX(), aDelta.getX(), rA.getY(), aDelta.getY(), rA.getZ(), aDelta.getZ()));
|
||||
return (maNormalInterpolators.size() - 1L);
|
||||
double aDeltaX(rB.getX() - rA.getX());
|
||||
|
||||
if(fTools::equalZero(aDeltaX))
|
||||
{
|
||||
aDeltaX = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
aDeltaX *= fInvYDelta;
|
||||
}
|
||||
|
||||
double aDeltaY(rB.getY() - rA.getY());
|
||||
|
||||
if(fTools::equalZero(aDeltaY))
|
||||
{
|
||||
aDeltaY = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
aDeltaY *= fInvYDelta;
|
||||
}
|
||||
|
||||
double aDeltaZ(rB.getZ() - rA.getZ());
|
||||
|
||||
if(fTools::equalZero(aDeltaZ))
|
||||
{
|
||||
aDeltaZ = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
aDeltaZ *= fInvYDelta;
|
||||
}
|
||||
|
||||
maNormalInterpolators.push_back(
|
||||
ip_triple(
|
||||
rA.getX(), aDeltaX,
|
||||
rA.getY(), aDeltaY,
|
||||
rA.getZ(), aDeltaZ));
|
||||
|
||||
return (maNormalInterpolators.size() - 1);
|
||||
}
|
||||
|
||||
sal_uInt32 addTextureInterpolator(const B2DPoint& rA, const B2DPoint& rB, double fInvYDelta)
|
||||
{
|
||||
B2DVector aDelta(rB.getX() - rA.getX(), rB.getY() - rA.getY());
|
||||
aDelta *= fInvYDelta;
|
||||
maTextureInterpolators.push_back(ip_double(rA.getX(), aDelta.getX(), rA.getY(), aDelta.getY()));
|
||||
return (maTextureInterpolators.size() - 1L);
|
||||
double aDeltaX(rB.getX() - rA.getX());
|
||||
|
||||
if(fTools::equalZero(aDeltaX))
|
||||
{
|
||||
aDeltaX = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
aDeltaX *= fInvYDelta;
|
||||
}
|
||||
|
||||
double aDeltaY(rB.getY() - rA.getY());
|
||||
|
||||
if(fTools::equalZero(aDeltaY))
|
||||
{
|
||||
aDeltaY = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
aDeltaY *= fInvYDelta;
|
||||
}
|
||||
|
||||
maTextureInterpolators.push_back(
|
||||
ip_double(
|
||||
rA.getX(), aDeltaX,
|
||||
rA.getY(), aDeltaY));
|
||||
|
||||
return (maTextureInterpolators.size() - 1);
|
||||
}
|
||||
|
||||
sal_uInt32 addInverseTextureInterpolator(const B2DPoint& rA, const B2DPoint& rB, double fZEyeA, double fZEyeB, double fInvYDelta)
|
||||
{
|
||||
double fZDelta(fZEyeB - fZEyeA);
|
||||
const double fInvZEyeA(fTools::equalZero(fZEyeA) ? fZEyeA : 1.0 / fZEyeA);
|
||||
const double fInvZEyeB(fTools::equalZero(fZEyeB) ? fZEyeB : 1.0 / fZEyeB);
|
||||
double fInvZEyeB(fInvZEyeA);
|
||||
|
||||
if(fTools::equalZero(fZDelta))
|
||||
{
|
||||
fZDelta = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fInvZEyeB = fTools::equalZero(fZEyeB) ? fZEyeB : 1.0 / fZEyeB;
|
||||
fZDelta = (fInvZEyeB - fInvZEyeA) * fInvYDelta;
|
||||
}
|
||||
|
||||
const B2DPoint aInvA(rA * fInvZEyeA);
|
||||
const B2DPoint aInvB(rB * fInvZEyeB);
|
||||
double fZDelta(fInvZEyeB - fInvZEyeA);
|
||||
B2DVector aDelta(aInvB.getX() - aInvA.getX(), aInvB.getY() - aInvA.getY());
|
||||
const double aDeltaX((aInvB.getX() - aInvA.getX()) * fInvYDelta);
|
||||
const double aDeltaY((aInvB.getY() - aInvA.getY()) * fInvYDelta);
|
||||
|
||||
fZDelta *= fInvYDelta;
|
||||
aDelta *= fInvYDelta;
|
||||
maInverseTextureInterpolators.push_back(
|
||||
ip_triple(
|
||||
aInvA.getX(), aDeltaX,
|
||||
aInvA.getY(), aDeltaY,
|
||||
fInvZEyeA, fZDelta));
|
||||
|
||||
maInverseTextureInterpolators.push_back(ip_triple(aInvA.getX(), aDelta.getX(), aInvA.getY(), aDelta.getY(), fInvZEyeA, fZDelta));
|
||||
return (maInverseTextureInterpolators.size() - 1L);
|
||||
return (maInverseTextureInterpolators.size() - 1);
|
||||
}
|
||||
|
||||
void reset()
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <sal/types.h>
|
||||
#include <basegfx/numeric/ftools.hxx>
|
||||
#include <algorithm>
|
||||
#include <basegfx/basegfxdllapi.h>
|
||||
|
||||
namespace basegfx
|
||||
@@ -237,50 +238,60 @@ namespace basegfx
|
||||
|
||||
inline B2DTuple minimum(const B2DTuple& rTupA, const B2DTuple& rTupB)
|
||||
{
|
||||
B2DTuple aMin(
|
||||
(rTupB.getX() < rTupA.getX()) ? rTupB.getX() : rTupA.getX(),
|
||||
(rTupB.getY() < rTupA.getY()) ? rTupB.getY() : rTupA.getY());
|
||||
return aMin;
|
||||
return B2DTuple(
|
||||
std::min(rTupB.getX(), rTupA.getX()),
|
||||
std::min(rTupB.getY(), rTupA.getY()));
|
||||
}
|
||||
|
||||
inline B2DTuple maximum(const B2DTuple& rTupA, const B2DTuple& rTupB)
|
||||
{
|
||||
B2DTuple aMax(
|
||||
(rTupB.getX() > rTupA.getX()) ? rTupB.getX() : rTupA.getX(),
|
||||
(rTupB.getY() > rTupA.getY()) ? rTupB.getY() : rTupA.getY());
|
||||
return aMax;
|
||||
return B2DTuple(
|
||||
std::max(rTupB.getX(), rTupA.getX()),
|
||||
std::max(rTupB.getY(), rTupA.getY()));
|
||||
}
|
||||
|
||||
inline B2DTuple absolute(const B2DTuple& rTup)
|
||||
{
|
||||
B2DTuple aAbs(
|
||||
(0.0 > rTup.getX()) ? -rTup.getX() : rTup.getX(),
|
||||
(0.0 > rTup.getY()) ? -rTup.getY() : rTup.getY());
|
||||
fabs(rTup.getX()),
|
||||
fabs(rTup.getY()));
|
||||
return aAbs;
|
||||
}
|
||||
|
||||
inline B2DTuple interpolate(const B2DTuple& rOld1, const B2DTuple& rOld2, double t)
|
||||
{
|
||||
B2DTuple aInt(
|
||||
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
|
||||
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY());
|
||||
return aInt;
|
||||
if(rOld1 == rOld2)
|
||||
{
|
||||
return rOld1;
|
||||
}
|
||||
else if(0.0 >= t)
|
||||
{
|
||||
return rOld1;
|
||||
}
|
||||
else if(1.0 <= t)
|
||||
{
|
||||
return rOld2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return B2DTuple(
|
||||
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
|
||||
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY());
|
||||
}
|
||||
}
|
||||
|
||||
inline B2DTuple average(const B2DTuple& rOld1, const B2DTuple& rOld2)
|
||||
{
|
||||
B2DTuple aAvg(
|
||||
(rOld1.getX() + rOld2.getX()) * 0.5,
|
||||
(rOld1.getY() + rOld2.getY()) * 0.5);
|
||||
return aAvg;
|
||||
return B2DTuple(
|
||||
rOld1.getX() == rOld2.getX() ? rOld1.getX() : (rOld1.getX() + rOld2.getX()) * 0.5,
|
||||
rOld1.getY() == rOld2.getY() ? rOld1.getY() : (rOld1.getY() + rOld2.getY()) * 0.5);
|
||||
}
|
||||
|
||||
inline B2DTuple average(const B2DTuple& rOld1, const B2DTuple& rOld2, const B2DTuple& 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;
|
||||
return B2DTuple(
|
||||
(rOld1.getX() == rOld2.getX() && rOld2.getX() == rOld3.getX()) ? rOld1.getX() : (rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0),
|
||||
(rOld1.getY() == rOld2.getY() && rOld2.getY() == rOld3.getY()) ? rOld1.getY() : (rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0));
|
||||
}
|
||||
|
||||
inline B2DTuple operator+(const B2DTuple& rTupA, const B2DTuple& rTupB)
|
||||
|
@@ -196,18 +196,16 @@ namespace basegfx
|
||||
|
||||
inline B2I64Tuple minimum(const B2I64Tuple& rTupA, const B2I64Tuple& rTupB)
|
||||
{
|
||||
B2I64Tuple aMin(
|
||||
(rTupB.getX() < rTupA.getX()) ? rTupB.getX() : rTupA.getX(),
|
||||
(rTupB.getY() < rTupA.getY()) ? rTupB.getY() : rTupA.getY());
|
||||
return aMin;
|
||||
return B2I64Tuple(
|
||||
std::min(rTupB.getX(), rTupA.getX()),
|
||||
std::min(rTupB.getY(), rTupA.getY()));
|
||||
}
|
||||
|
||||
inline B2I64Tuple maximum(const B2I64Tuple& rTupA, const B2I64Tuple& rTupB)
|
||||
{
|
||||
B2I64Tuple aMax(
|
||||
(rTupB.getX() > rTupA.getX()) ? rTupB.getX() : rTupA.getX(),
|
||||
(rTupB.getY() > rTupA.getY()) ? rTupB.getY() : rTupA.getY());
|
||||
return aMax;
|
||||
return B2I64Tuple(
|
||||
std::max(rTupB.getX(), rTupA.getX()),
|
||||
std::max(rTupB.getY(), rTupA.getY()));
|
||||
}
|
||||
|
||||
inline B2I64Tuple absolute(const B2I64Tuple& rTup)
|
||||
@@ -218,28 +216,40 @@ namespace basegfx
|
||||
return aAbs;
|
||||
}
|
||||
|
||||
inline B2DTuple interpolate(const B2I64Tuple& rOld1, const B2I64Tuple& rOld2, double t)
|
||||
inline B2I64Tuple interpolate(const B2I64Tuple& rOld1, const B2I64Tuple& rOld2, double t)
|
||||
{
|
||||
B2DTuple aInt(
|
||||
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
|
||||
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY());
|
||||
return aInt;
|
||||
if(rOld1 == rOld2)
|
||||
{
|
||||
return rOld1;
|
||||
}
|
||||
else if(0.0 >= t)
|
||||
{
|
||||
return rOld1;
|
||||
}
|
||||
else if(1.0 <= t)
|
||||
{
|
||||
return rOld2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return B2I64Tuple(
|
||||
basegfx::fround64(((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX()),
|
||||
basegfx::fround64(((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY()));
|
||||
}
|
||||
}
|
||||
|
||||
inline B2DTuple average(const B2I64Tuple& rOld1, const B2I64Tuple& rOld2)
|
||||
inline B2I64Tuple average(const B2I64Tuple& rOld1, const B2I64Tuple& rOld2)
|
||||
{
|
||||
B2DTuple aAvg(
|
||||
(rOld1.getX() + rOld2.getX()) * 0.5,
|
||||
(rOld1.getY() + rOld2.getY()) * 0.5);
|
||||
return aAvg;
|
||||
return B2I64Tuple(
|
||||
rOld1.getX() == rOld2.getX() ? rOld1.getX() : basegfx::fround64((rOld1.getX() + rOld2.getX()) * 0.5),
|
||||
rOld1.getY() == rOld2.getY() ? rOld1.getY() : basegfx::fround64((rOld1.getY() + rOld2.getY()) * 0.5));
|
||||
}
|
||||
|
||||
inline B2DTuple average(const B2I64Tuple& rOld1, const B2I64Tuple& rOld2, const B2I64Tuple& rOld3)
|
||||
inline B2I64Tuple average(const B2I64Tuple& rOld1, const B2I64Tuple& rOld2, const B2I64Tuple& 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;
|
||||
return B2I64Tuple(
|
||||
(rOld1.getX() == rOld2.getX() && rOld2.getX() == rOld3.getX()) ? rOld1.getX() : basegfx::fround64((rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0)),
|
||||
(rOld1.getY() == rOld2.getY() && rOld2.getY() == rOld3.getY()) ? rOld1.getY() : basegfx::fround64((rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0)));
|
||||
}
|
||||
|
||||
inline B2I64Tuple operator+(const B2I64Tuple& rTupA, const B2I64Tuple& rTupB)
|
||||
|
@@ -21,6 +21,8 @@
|
||||
#define _BGFX_TUPLE_B2ITUPLE_HXX
|
||||
|
||||
#include <sal/types.h>
|
||||
#include <basegfx/numeric/ftools.hxx>
|
||||
#include <algorithm>
|
||||
#include <basegfx/basegfxdllapi.h>
|
||||
|
||||
namespace basegfx
|
||||
@@ -169,7 +171,10 @@ namespace basegfx
|
||||
return B2ITuple(-mnX, -mnY);
|
||||
}
|
||||
|
||||
bool equalZero() const { return mnX == 0 && mnY == 0; }
|
||||
bool equalZero() const
|
||||
{
|
||||
return mnX == 0 && mnY == 0;
|
||||
}
|
||||
|
||||
bool operator==( const B2ITuple& rTup ) const
|
||||
{
|
||||
@@ -191,16 +196,65 @@ namespace basegfx
|
||||
|
||||
// external operators
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class B2DTuple;
|
||||
|
||||
BASEGFX_DLLPUBLIC B2ITuple operator+(const B2ITuple& rTupA, const B2ITuple& rTupB);
|
||||
BASEGFX_DLLPUBLIC B2ITuple operator-(const B2ITuple& rTupA, const B2ITuple& rTupB);
|
||||
BASEGFX_DLLPUBLIC B2ITuple operator/(const B2ITuple& rTupA, const B2ITuple& rTupB);
|
||||
BASEGFX_DLLPUBLIC B2ITuple operator*(const B2ITuple& rTupA, const B2ITuple& rTupB);
|
||||
BASEGFX_DLLPUBLIC B2ITuple operator*(const B2ITuple& rTup, sal_Int32 t);
|
||||
BASEGFX_DLLPUBLIC B2ITuple operator*(sal_Int32 t, const B2ITuple& rTup);
|
||||
BASEGFX_DLLPUBLIC B2ITuple operator/(const B2ITuple& rTup, sal_Int32 t);
|
||||
BASEGFX_DLLPUBLIC B2ITuple operator/(sal_Int32 t, const B2ITuple& rTup);
|
||||
|
||||
BASEGFX_DLLPUBLIC inline B2ITuple operator+(const B2ITuple& rTupA, const B2ITuple& rTupB)
|
||||
{
|
||||
B2ITuple aSum(rTupA);
|
||||
aSum += rTupB;
|
||||
return aSum;
|
||||
}
|
||||
|
||||
BASEGFX_DLLPUBLIC inline B2ITuple operator-(const B2ITuple& rTupA, const B2ITuple& rTupB)
|
||||
{
|
||||
B2ITuple aSub(rTupA);
|
||||
aSub -= rTupB;
|
||||
return aSub;
|
||||
}
|
||||
|
||||
BASEGFX_DLLPUBLIC inline B2ITuple operator/(const B2ITuple& rTupA, const B2ITuple& rTupB)
|
||||
{
|
||||
B2ITuple aDiv(rTupA);
|
||||
aDiv /= rTupB;
|
||||
return aDiv;
|
||||
}
|
||||
|
||||
BASEGFX_DLLPUBLIC inline B2ITuple operator*(const B2ITuple& rTupA, const B2ITuple& rTupB)
|
||||
{
|
||||
B2ITuple aMul(rTupA);
|
||||
aMul *= rTupB;
|
||||
return aMul;
|
||||
}
|
||||
|
||||
BASEGFX_DLLPUBLIC inline B2ITuple operator*(const B2ITuple& rTup, sal_Int32 t)
|
||||
{
|
||||
B2ITuple aNew(rTup);
|
||||
aNew *= t;
|
||||
return aNew;
|
||||
}
|
||||
|
||||
BASEGFX_DLLPUBLIC inline B2ITuple operator*(sal_Int32 t, const B2ITuple& rTup)
|
||||
{
|
||||
B2ITuple aNew(rTup);
|
||||
aNew *= t;
|
||||
return aNew;
|
||||
}
|
||||
|
||||
BASEGFX_DLLPUBLIC inline B2ITuple operator/(const B2ITuple& rTup, sal_Int32 t)
|
||||
{
|
||||
B2ITuple aNew(rTup);
|
||||
aNew /= t;
|
||||
return aNew;
|
||||
}
|
||||
|
||||
BASEGFX_DLLPUBLIC inline B2ITuple operator/(sal_Int32 t, const B2ITuple& rTup)
|
||||
{
|
||||
B2ITuple aNew(t, t);
|
||||
B2ITuple aTmp(rTup);
|
||||
aNew /= aTmp;
|
||||
return aNew;
|
||||
}
|
||||
|
||||
} // end of namespace basegfx
|
||||
|
||||
#endif /* _BGFX_TUPLE_B2ITUPLE_HXX */
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <sal/types.h>
|
||||
#include <basegfx/numeric/ftools.hxx>
|
||||
#include <algorithm>
|
||||
#include <basegfx/basegfxdllapi.h>
|
||||
|
||||
namespace basegfx
|
||||
@@ -301,56 +302,66 @@ namespace basegfx
|
||||
|
||||
inline B3DTuple minimum(const B3DTuple& rTupA, const B3DTuple& rTupB)
|
||||
{
|
||||
B3DTuple aMin(
|
||||
(rTupB.getX() < rTupA.getX()) ? rTupB.getX() : rTupA.getX(),
|
||||
(rTupB.getY() < rTupA.getY()) ? rTupB.getY() : rTupA.getY(),
|
||||
(rTupB.getZ() < rTupA.getZ()) ? rTupB.getZ() : rTupA.getZ());
|
||||
return aMin;
|
||||
return B3DTuple(
|
||||
std::min(rTupB.getX(), rTupA.getX()),
|
||||
std::min(rTupB.getY(), rTupA.getY()),
|
||||
std::min(rTupB.getZ(), rTupA.getZ()));
|
||||
}
|
||||
|
||||
inline B3DTuple maximum(const B3DTuple& rTupA, const B3DTuple& rTupB)
|
||||
{
|
||||
B3DTuple aMax(
|
||||
(rTupB.getX() > rTupA.getX()) ? rTupB.getX() : rTupA.getX(),
|
||||
(rTupB.getY() > rTupA.getY()) ? rTupB.getY() : rTupA.getY(),
|
||||
(rTupB.getZ() > rTupA.getZ()) ? rTupB.getZ() : rTupA.getZ());
|
||||
return aMax;
|
||||
return B3DTuple(
|
||||
std::max(rTupB.getX(), rTupA.getX()),
|
||||
std::max(rTupB.getY(), rTupA.getY()),
|
||||
std::max(rTupB.getZ(), rTupA.getZ()));
|
||||
}
|
||||
|
||||
inline B3DTuple absolute(const B3DTuple& rTup)
|
||||
{
|
||||
B3DTuple aAbs(
|
||||
(0.0 > rTup.getX()) ? -rTup.getX() : rTup.getX(),
|
||||
(0.0 > rTup.getY()) ? -rTup.getY() : rTup.getY(),
|
||||
(0.0 > rTup.getZ()) ? -rTup.getZ() : rTup.getZ());
|
||||
fabs(rTup.getX()),
|
||||
fabs(rTup.getY()),
|
||||
fabs(rTup.getZ()));
|
||||
return aAbs;
|
||||
}
|
||||
|
||||
inline B3DTuple interpolate(const B3DTuple& rOld1, const B3DTuple& rOld2, double t)
|
||||
{
|
||||
B3DTuple aInt(
|
||||
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
|
||||
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY(),
|
||||
((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ());
|
||||
return aInt;
|
||||
if(rOld1 == rOld2)
|
||||
{
|
||||
return rOld1;
|
||||
}
|
||||
else if(0.0 >= t)
|
||||
{
|
||||
return rOld1;
|
||||
}
|
||||
else if(1.0 <= t)
|
||||
{
|
||||
return rOld2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return B3DTuple(
|
||||
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
|
||||
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY(),
|
||||
((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
inline B3DTuple average(const B3DTuple& rOld1, const B3DTuple& rOld2)
|
||||
{
|
||||
B3DTuple aAvg(
|
||||
(rOld1.getX() + rOld2.getX()) * 0.5,
|
||||
(rOld1.getY() + rOld2.getY()) * 0.5,
|
||||
(rOld1.getZ() + rOld2.getZ()) * 0.5);
|
||||
return aAvg;
|
||||
return B3DTuple(
|
||||
rOld1.getX() == rOld2.getX() ? rOld1.getX() : (rOld1.getX() + rOld2.getX()) * 0.5,
|
||||
rOld1.getY() == rOld2.getY() ? rOld1.getY() : (rOld1.getY() + rOld2.getY()) * 0.5,
|
||||
rOld1.getZ() == rOld2.getZ() ? rOld1.getZ() : (rOld1.getZ() + rOld2.getZ()) * 0.5);
|
||||
}
|
||||
|
||||
inline B3DTuple average(const B3DTuple& rOld1, const B3DTuple& rOld2, const B3DTuple& rOld3)
|
||||
{
|
||||
B3DTuple aAvg(
|
||||
(rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0),
|
||||
(rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0),
|
||||
(rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0));
|
||||
return aAvg;
|
||||
return B3DTuple(
|
||||
(rOld1.getX() == rOld2.getX() && rOld2.getX() == rOld3.getX()) ? rOld1.getX() : (rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0),
|
||||
(rOld1.getY() == rOld2.getY() && rOld2.getY() == rOld3.getY()) ? rOld1.getY() : (rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0),
|
||||
(rOld1.getZ() == rOld2.getZ() && rOld2.getZ() == rOld3.getZ()) ? rOld1.getZ() : (rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0));
|
||||
}
|
||||
|
||||
inline B3DTuple operator+(const B3DTuple& rTupA, const B3DTuple& rTupB)
|
||||
|
@@ -221,20 +221,18 @@ namespace basegfx
|
||||
|
||||
inline B3I64Tuple minimum(const B3I64Tuple& rTupA, const B3I64Tuple& rTupB)
|
||||
{
|
||||
B3I64Tuple aMin(
|
||||
(rTupB.getX() < rTupA.getX()) ? rTupB.getX() : rTupA.getX(),
|
||||
(rTupB.getY() < rTupA.getY()) ? rTupB.getY() : rTupA.getY(),
|
||||
(rTupB.getZ() < rTupA.getZ()) ? rTupB.getZ() : rTupA.getZ());
|
||||
return aMin;
|
||||
return B3I64Tuple(
|
||||
std::min(rTupB.getX(), rTupA.getX()),
|
||||
std::min(rTupB.getY(), rTupA.getY()),
|
||||
std::min(rTupB.getZ(), rTupA.getZ()));
|
||||
}
|
||||
|
||||
inline B3I64Tuple maximum(const B3I64Tuple& rTupA, const B3I64Tuple& rTupB)
|
||||
{
|
||||
B3I64Tuple aMax(
|
||||
(rTupB.getX() > rTupA.getX()) ? rTupB.getX() : rTupA.getX(),
|
||||
(rTupB.getY() > rTupA.getY()) ? rTupB.getY() : rTupA.getY(),
|
||||
(rTupB.getZ() > rTupA.getZ()) ? rTupB.getZ() : rTupA.getZ());
|
||||
return aMax;
|
||||
return B3I64Tuple(
|
||||
std::max(rTupB.getX(), rTupA.getX()),
|
||||
std::max(rTupB.getY(), rTupA.getY()),
|
||||
std::max(rTupB.getZ(), rTupA.getZ()));
|
||||
}
|
||||
|
||||
inline B3I64Tuple absolute(const B3I64Tuple& rTup)
|
||||
@@ -246,31 +244,43 @@ namespace basegfx
|
||||
return aAbs;
|
||||
}
|
||||
|
||||
inline B3DTuple interpolate(const B3I64Tuple& rOld1, const B3I64Tuple& rOld2, double t)
|
||||
inline B3I64Tuple interpolate(const B3I64Tuple& rOld1, const B3I64Tuple& rOld2, double t)
|
||||
{
|
||||
B3DTuple aInt(
|
||||
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
|
||||
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY(),
|
||||
((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ());
|
||||
return aInt;
|
||||
if(rOld1 == rOld2)
|
||||
{
|
||||
return rOld1;
|
||||
}
|
||||
else if(0.0 >= t)
|
||||
{
|
||||
return rOld1;
|
||||
}
|
||||
else if(1.0 <= t)
|
||||
{
|
||||
return rOld2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return B3I64Tuple(
|
||||
basegfx::fround64(((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX()),
|
||||
basegfx::fround64(((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY()),
|
||||
basegfx::fround64(((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
inline B3DTuple average(const B3I64Tuple& rOld1, const B3I64Tuple& rOld2)
|
||||
inline B3I64Tuple average(const B3I64Tuple& rOld1, const B3I64Tuple& rOld2)
|
||||
{
|
||||
B3DTuple aAvg(
|
||||
(rOld1.getX() + rOld2.getX()) * 0.5,
|
||||
(rOld1.getY() + rOld2.getY()) * 0.5,
|
||||
(rOld1.getZ() + rOld2.getZ()) * 0.5);
|
||||
return aAvg;
|
||||
return B3I64Tuple(
|
||||
rOld1.getX() == rOld2.getX() ? rOld1.getX() : basegfx::fround64((rOld1.getX() + rOld2.getX()) * 0.5),
|
||||
rOld1.getY() == rOld2.getY() ? rOld1.getY() : basegfx::fround64((rOld1.getY() + rOld2.getY()) * 0.5),
|
||||
rOld1.getZ() == rOld2.getZ() ? rOld1.getZ() : basegfx::fround64((rOld1.getZ() + rOld2.getZ()) * 0.5));
|
||||
}
|
||||
|
||||
inline B3DTuple average(const B3I64Tuple& rOld1, const B3I64Tuple& rOld2, const B3I64Tuple& rOld3)
|
||||
inline B3I64Tuple average(const B3I64Tuple& rOld1, const B3I64Tuple& rOld2, const B3I64Tuple& rOld3)
|
||||
{
|
||||
B3DTuple aAvg(
|
||||
(rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0),
|
||||
(rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0),
|
||||
(rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0));
|
||||
return aAvg;
|
||||
return B3I64Tuple(
|
||||
(rOld1.getX() == rOld2.getX() && rOld2.getX() == rOld3.getX()) ? rOld1.getX() : basegfx::fround64((rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0)),
|
||||
(rOld1.getY() == rOld2.getY() && rOld2.getY() == rOld3.getY()) ? rOld1.getY() : basegfx::fround64((rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0)),
|
||||
(rOld1.getZ() == rOld2.getZ() && rOld2.getZ() == rOld3.getZ()) ? rOld1.getZ() : basegfx::fround64((rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0)));
|
||||
}
|
||||
|
||||
inline B3I64Tuple operator+(const B3I64Tuple& rTupA, const B3I64Tuple& rTupB)
|
||||
|
@@ -220,20 +220,18 @@ namespace basegfx
|
||||
|
||||
inline B3ITuple minimum(const B3ITuple& rTupA, const B3ITuple& rTupB)
|
||||
{
|
||||
B3ITuple aMin(
|
||||
(rTupB.getX() < rTupA.getX()) ? rTupB.getX() : rTupA.getX(),
|
||||
(rTupB.getY() < rTupA.getY()) ? rTupB.getY() : rTupA.getY(),
|
||||
(rTupB.getZ() < rTupA.getZ()) ? rTupB.getZ() : rTupA.getZ());
|
||||
return aMin;
|
||||
return B3ITuple(
|
||||
std::min(rTupB.getX(), rTupA.getX()),
|
||||
std::min(rTupB.getY(), rTupA.getY()),
|
||||
std::min(rTupB.getZ(), rTupA.getZ()));
|
||||
}
|
||||
|
||||
inline B3ITuple maximum(const B3ITuple& rTupA, const B3ITuple& rTupB)
|
||||
{
|
||||
B3ITuple aMax(
|
||||
(rTupB.getX() > rTupA.getX()) ? rTupB.getX() : rTupA.getX(),
|
||||
(rTupB.getY() > rTupA.getY()) ? rTupB.getY() : rTupA.getY(),
|
||||
(rTupB.getZ() > rTupA.getZ()) ? rTupB.getZ() : rTupA.getZ());
|
||||
return aMax;
|
||||
return B3ITuple(
|
||||
std::max(rTupB.getX(), rTupA.getX()),
|
||||
std::max(rTupB.getY(), rTupA.getY()),
|
||||
std::max(rTupB.getZ(), rTupA.getZ()));
|
||||
}
|
||||
|
||||
inline B3ITuple absolute(const B3ITuple& rTup)
|
||||
@@ -245,31 +243,43 @@ namespace basegfx
|
||||
return aAbs;
|
||||
}
|
||||
|
||||
inline B3DTuple interpolate(const B3ITuple& rOld1, const B3ITuple& rOld2, double t)
|
||||
inline B3ITuple interpolate(const B3ITuple& rOld1, const B3ITuple& rOld2, double t)
|
||||
{
|
||||
B3DTuple aInt(
|
||||
((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX(),
|
||||
((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY(),
|
||||
((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ());
|
||||
return aInt;
|
||||
if(rOld1 == rOld2)
|
||||
{
|
||||
return rOld1;
|
||||
}
|
||||
else if(0.0 >= t)
|
||||
{
|
||||
return rOld1;
|
||||
}
|
||||
else if(1.0 <= t)
|
||||
{
|
||||
return rOld2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return B3ITuple(
|
||||
basegfx::fround(((rOld2.getX() - rOld1.getX()) * t) + rOld1.getX()),
|
||||
basegfx::fround(((rOld2.getY() - rOld1.getY()) * t) + rOld1.getY()),
|
||||
basegfx::fround(((rOld2.getZ() - rOld1.getZ()) * t) + rOld1.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
inline B3DTuple average(const B3ITuple& rOld1, const B3ITuple& rOld2)
|
||||
inline B3ITuple average(const B3ITuple& rOld1, const B3ITuple& rOld2)
|
||||
{
|
||||
B3DTuple aAvg(
|
||||
(rOld1.getX() + rOld2.getX()) * 0.5,
|
||||
(rOld1.getY() + rOld2.getY()) * 0.5,
|
||||
(rOld1.getZ() + rOld2.getZ()) * 0.5);
|
||||
return aAvg;
|
||||
return B3ITuple(
|
||||
rOld1.getX() == rOld2.getX() ? rOld1.getX() : basegfx::fround((rOld1.getX() + rOld2.getX()) * 0.5),
|
||||
rOld1.getY() == rOld2.getY() ? rOld1.getY() : basegfx::fround((rOld1.getY() + rOld2.getY()) * 0.5),
|
||||
rOld1.getZ() == rOld2.getZ() ? rOld1.getZ() : basegfx::fround((rOld1.getZ() + rOld2.getZ()) * 0.5));
|
||||
}
|
||||
|
||||
inline B3DTuple average(const B3ITuple& rOld1, const B3ITuple& rOld2, const B3ITuple& rOld3)
|
||||
inline B3ITuple average(const B3ITuple& rOld1, const B3ITuple& rOld2, const B3ITuple& rOld3)
|
||||
{
|
||||
B3DTuple aAvg(
|
||||
(rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0),
|
||||
(rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0),
|
||||
(rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0));
|
||||
return aAvg;
|
||||
return B3ITuple(
|
||||
(rOld1.getX() == rOld2.getX() && rOld2.getX() == rOld3.getX()) ? rOld1.getX() : basegfx::fround((rOld1.getX() + rOld2.getX() + rOld3.getX()) * (1.0 / 3.0)),
|
||||
(rOld1.getY() == rOld2.getY() && rOld2.getY() == rOld3.getY()) ? rOld1.getX() : basegfx::fround((rOld1.getY() + rOld2.getY() + rOld3.getY()) * (1.0 / 3.0)),
|
||||
(rOld1.getZ() == rOld2.getZ() && rOld2.getZ() == rOld3.getZ()) ? rOld1.getX() : basegfx::fround((rOld1.getZ() + rOld2.getZ() + rOld3.getZ()) * (1.0 / 3.0)));
|
||||
}
|
||||
|
||||
inline B3ITuple operator+(const B3ITuple& rTupA, const B3ITuple& rTupB)
|
||||
|
Reference in New Issue
Block a user