summaryrefslogtreecommitdiff
path: root/basegfx/source
diff options
context:
space:
mode:
Diffstat (limited to 'basegfx/source')
-rw-r--r--basegfx/source/inc/hommatrixtemplate.hxx876
-rw-r--r--basegfx/source/matrix/b2dhommatrix.cxx24
-rw-r--r--basegfx/source/matrix/b3dhommatrix.cxx24
3 files changed, 466 insertions, 458 deletions
diff --git a/basegfx/source/inc/hommatrixtemplate.hxx b/basegfx/source/inc/hommatrixtemplate.hxx
index c1c81288c04e..9711dd4e3c01 100644
--- a/basegfx/source/inc/hommatrixtemplate.hxx
+++ b/basegfx/source/inc/hommatrixtemplate.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: hommatrixtemplate.hxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:50 $
+ * last change: $Author: thb $ $Date: 2003-11-10 15:10:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,571 +73,579 @@
#include <math.h>
#include <string.h>
-inline double implGetDefaultValue(sal_uInt16 nRow, sal_uInt16 nColumn)
+namespace basegfx
{
- if(nRow == nColumn)
- return 1.0;
- return 0.0;
-}
-
-template < int _RowSize > class ImplMatLine
-{
- enum { RowSize = _RowSize };
-
- double mfValue[RowSize];
-
-public:
- ImplMatLine(sal_uInt16 nRow = 0L, ImplMatLine< RowSize >* pToBeCopied = 0L)
+ namespace internal
{
- if(pToBeCopied)
+
+ inline double implGetDefaultValue(sal_uInt16 nRow, sal_uInt16 nColumn)
{
- memcpy(&mfValue, pToBeCopied, sizeof(double) * RowSize);
+ if(nRow == nColumn)
+ return 1.0;
+ return 0.0;
}
- else
- {
- for(sal_uInt16 a(0); a < RowSize; a++)
- {
- mfValue[a] = implGetDefaultValue(nRow, a);
- }
- }
- }
-
- double get(sal_uInt16 nColumn) const
- {
- return mfValue[nColumn];
- }
-
- void set(sal_uInt16 nColumn, const double& rValue)
- {
- mfValue[nColumn] = rValue;
- }
-};
-template < int _RowSize > class ImplHomMatrixTemplate
-{
- enum { RowSize = _RowSize };
-
- sal_uInt32 mnRefCount;
-
- ImplMatLine< RowSize > maLine[RowSize - 1];
- ImplMatLine< RowSize >* mpLine;
-
-public:
- // Is last line used?
- sal_Bool isLastLineDefault() const
- {
- if(!mpLine)
- return sal_True;
-
- for(sal_uInt16 a(0); a < RowSize; a++)
+ template < int _RowSize > class ImplMatLine
{
- const double fDefault(implGetDefaultValue((RowSize - 1), a));
- const double fLineValue(mpLine->get(a));
+ enum { RowSize = _RowSize };
+
+ double mfValue[RowSize];
- if(!::basegfx::numeric::fTools::equal(fDefault, fLineValue))
+ public:
+ ImplMatLine(sal_uInt16 nRow = 0L, ImplMatLine< RowSize >* pToBeCopied = 0L)
{
- return sal_False;
+ if(pToBeCopied)
+ {
+ memcpy(&mfValue, pToBeCopied, sizeof(double) * RowSize);
+ }
+ else
+ {
+ for(sal_uInt16 a(0); a < RowSize; a++)
+ {
+ mfValue[a] = implGetDefaultValue(nRow, a);
+ }
+ }
}
- }
- // reset last line, it equals default
- delete ((ImplHomMatrixTemplate< RowSize >*)this)->mpLine;
- ((ImplHomMatrixTemplate< RowSize >*)this)->mpLine = 0L;
-
- return sal_True;
- }
-
- // This constructor is only used form the static identity matrix, thus
- // the RefCount is set to 1 to never 'delete' this static incarnation.
- ImplHomMatrixTemplate()
- : mnRefCount(1),
- mpLine(0L)
- {
- // complete initialization with identity matrix, all lines
- // were initialized with a trailing 1 followed by 0's.
- for(sal_uInt16 a(1); a < (RowSize - 1); a++)
- {
- maLine[a].set(0, 0.0);
- maLine[a].set(a, 1.0);
- }
- }
+ double get(sal_uInt16 nColumn) const
+ {
+ return mfValue[nColumn];
+ }
- ImplHomMatrixTemplate(const ImplHomMatrixTemplate& rToBeCopied)
- : mnRefCount(0),
- mpLine(0L)
- {
- // complete initialization using copy
- for(sal_uInt16 a(0); a < (RowSize - 1); a++)
- {
- memcpy(&maLine[a], &rToBeCopied.maLine[a], sizeof(ImplMatLine< RowSize >));
- }
+ void set(sal_uInt16 nColumn, const double& rValue)
+ {
+ mfValue[nColumn] = rValue;
+ }
+ };
- if(rToBeCopied.mpLine)
+ template < int _RowSize > class ImplHomMatrixTemplate
{
- mpLine = new ImplMatLine< RowSize >((RowSize - 1), rToBeCopied.mpLine);
- }
- }
+ enum { RowSize = _RowSize };
- ~ImplHomMatrixTemplate()
- {
- if(mpLine)
- {
- delete mpLine;
- }
- }
+ sal_uInt32 mnRefCount;
- const sal_uInt32 getRefCount() const { return mnRefCount; }
- void incRefCount() { mnRefCount++; }
- void decRefCount() { mnRefCount--; }
+ ImplMatLine< RowSize > maLine[RowSize - 1];
+ ImplMatLine< RowSize >* mpLine;
- sal_uInt16 getEdgeLength() const { return RowSize; }
+ public:
+ // Is last line used?
+ sal_Bool isLastLineDefault() const
+ {
+ if(!mpLine)
+ return sal_True;
- double get(sal_uInt16 nRow, sal_uInt16 nColumn) const
- {
- if(nRow < (RowSize - 1))
- {
- return maLine[nRow].get(nColumn);
- }
+ for(sal_uInt16 a(0); a < RowSize; a++)
+ {
+ const double fDefault(implGetDefaultValue((RowSize - 1), a));
+ const double fLineValue(mpLine->get(a));
- if(mpLine)
- {
- return mpLine->get(nColumn);
- }
+ if(!::basegfx::numeric::fTools::equal(fDefault, fLineValue))
+ {
+ return sal_False;
+ }
+ }
- return implGetDefaultValue((RowSize - 1), nColumn);
- }
+ // reset last line, it equals default
+ delete ((ImplHomMatrixTemplate< RowSize >*)this)->mpLine;
+ ((ImplHomMatrixTemplate< RowSize >*)this)->mpLine = 0L;
- void set(sal_uInt16 nRow, sal_uInt16 nColumn, const double& rValue)
- {
- if(nRow < (RowSize - 1))
- {
- maLine[nRow].set(nColumn, rValue);
- }
- else if(mpLine)
- {
- mpLine->set(nColumn, rValue);
- }
- else
- {
- const double fDefault(implGetDefaultValue((RowSize - 1), nColumn));
-
- if(!::basegfx::numeric::fTools::equal(fDefault, rValue))
- {
- mpLine = new ImplMatLine< RowSize >((RowSize - 1), 0L);
- mpLine->set(nColumn, rValue);
+ return sal_True;
}
- }
- }
- void testLastLine()
- {
- if(mpLine)
- {
- sal_Bool bNecessary(sal_False);
-
- for(sal_uInt16 a(0);!bNecessary && a < RowSize; a++)
+ // This constructor is only used form the static identity matrix, thus
+ // the RefCount is set to 1 to never 'delete' this static incarnation.
+ ImplHomMatrixTemplate()
+ : mnRefCount(1),
+ mpLine(0L)
{
- const double fDefault(implGetDefaultValue((RowSize - 1), a));
- const double fLineValue(mpLine->get(a));
-
- if(!::basegfx::numeric::fTools::equal(fDefault, fLineValue))
+ // complete initialization with identity matrix, all lines
+ // were initialized with a trailing 1 followed by 0's.
+ for(sal_uInt16 a(1); a < (RowSize - 1); a++)
{
- bNecessary = sal_True;
+ maLine[a].set(0, 0.0);
+ maLine[a].set(a, 1.0);
}
}
- if(!bNecessary)
- {
- delete mpLine;
- mpLine = 0L;
- }
- }
- }
-
- // Left-upper decompositon
- sal_Bool ludcmp(sal_uInt16 nIndex[], sal_Int16& nParity)
- {
- double fBig, fSum, fDum;
- double fStorage[RowSize];
- sal_uInt16 a, b, c, nAMax;
-
- nParity = 1;
-
- // Calc the max of each line. If a line is empty,
- // stop immediately since matrix is not invertible then.
- for(a = 0; a < RowSize; a++)
- {
- fBig = 0.0;
-
- for(b = 0; b < RowSize; b++)
+ ImplHomMatrixTemplate(const ImplHomMatrixTemplate& rToBeCopied)
+ : mnRefCount(0),
+ mpLine(0L)
{
- double fTemp(fabs(get(a, b)));
+ // complete initialization using copy
+ for(sal_uInt16 a(0); a < (RowSize - 1); a++)
+ {
+ memcpy(&maLine[a], &rToBeCopied.maLine[a], sizeof(ImplMatLine< RowSize >));
+ }
- if(::basegfx::numeric::fTools::more(fTemp, fBig))
+ if(rToBeCopied.mpLine)
{
- fBig = fTemp;
+ mpLine = new ImplMatLine< RowSize >((RowSize - 1), rToBeCopied.mpLine);
}
}
- if(::basegfx::numeric::fTools::equalZero(fBig))
+ ~ImplHomMatrixTemplate()
{
- return sal_False;
+ if(mpLine)
+ {
+ delete mpLine;
+ }
}
- fStorage[a] = 1.0 / fBig;
- }
+ const sal_uInt32 getRefCount() const { return mnRefCount; }
+ void incRefCount() { mnRefCount++; }
+ void decRefCount() { mnRefCount--; }
- // start normalizing
- for(b = 0; b < RowSize; b++)
- {
- for(a = 0; a < b; a++)
+ sal_uInt16 getEdgeLength() const { return RowSize; }
+
+ double get(sal_uInt16 nRow, sal_uInt16 nColumn) const
{
- fSum = get(a, b);
+ if(nRow < (RowSize - 1))
+ {
+ return maLine[nRow].get(nColumn);
+ }
- for(c = 0; c < a; c++)
+ if(mpLine)
{
- fSum -= get(a, c) * get(c, b);
+ return mpLine->get(nColumn);
}
- set(a, b, fSum);
+ return implGetDefaultValue((RowSize - 1), nColumn);
}
- fBig = 0.0;
-
- for(a = b; a < RowSize; a++)
+ void set(sal_uInt16 nRow, sal_uInt16 nColumn, const double& rValue)
{
- fSum = get(a, b);
-
- for(c = 0; c < b; c++)
+ if(nRow < (RowSize - 1))
{
- fSum -= get(a, c) * get(c, b);
+ maLine[nRow].set(nColumn, rValue);
}
-
- set(a, b, fSum);
- fDum = fStorage[a] * fabs(fSum);
-
- if(::basegfx::numeric::fTools::moreOrEqual(fDum, fBig))
+ else if(mpLine)
+ {
+ mpLine->set(nColumn, rValue);
+ }
+ else
{
- fBig = fDum;
- nAMax = a;
+ const double fDefault(implGetDefaultValue((RowSize - 1), nColumn));
+
+ if(!::basegfx::numeric::fTools::equal(fDefault, rValue))
+ {
+ mpLine = new ImplMatLine< RowSize >((RowSize - 1), 0L);
+ mpLine->set(nColumn, rValue);
+ }
}
}
- if(b != nAMax)
+ void testLastLine()
{
- for(c = 0; c < RowSize; c++)
+ if(mpLine)
{
- fDum = get(nAMax, c);
- set(nAMax, c, get(b, c));
- set(b, c, fDum);
+ sal_Bool bNecessary(sal_False);
+
+ for(sal_uInt16 a(0);!bNecessary && a < RowSize; a++)
+ {
+ const double fDefault(implGetDefaultValue((RowSize - 1), a));
+ const double fLineValue(mpLine->get(a));
+
+ if(!::basegfx::numeric::fTools::equal(fDefault, fLineValue))
+ {
+ bNecessary = sal_True;
+ }
+ }
+
+ if(!bNecessary)
+ {
+ delete mpLine;
+ mpLine = 0L;
+ }
}
-
- nParity = -nParity;
- fStorage[nAMax] = fStorage[b];
}
- nIndex[b] = nAMax;
-
- // here the failure of precision occurs
- const double fValBB(fabs(get(b, b)));
-
- if(::basegfx::numeric::fTools::equalZero(fValBB))
+ // Left-upper decompositon
+ sal_Bool ludcmp(sal_uInt16 nIndex[], sal_Int16& nParity)
{
- return sal_False;
- }
+ double fBig, fSum, fDum;
+ double fStorage[RowSize];
+ sal_uInt16 a, b, c, nAMax;
- if(b != (RowSize - 1))
- {
- fDum = 1.0 / get(b, b);
+ nParity = 1;
- for(a = b + 1; a < RowSize; a++)
+ // Calc the max of each line. If a line is empty,
+ // stop immediately since matrix is not invertible then.
+ for(a = 0; a < RowSize; a++)
{
- set(a, b, get(a, b) * fDum);
- }
- }
- }
+ fBig = 0.0;
- return sal_True;
- }
+ for(b = 0; b < RowSize; b++)
+ {
+ double fTemp(fabs(get(a, b)));
- void lubksb(const sal_uInt16 nIndex[], double fRow[]) const
- {
- sal_uInt16 b, ip;
- sal_Int16 a, a2 = -1;
- double fSum;
+ if(::basegfx::numeric::fTools::more(fTemp, fBig))
+ {
+ fBig = fTemp;
+ }
+ }
- for(a = 0; a < RowSize; a++)
- {
- ip = nIndex[a];
- fSum = fRow[ip];
- fRow[ip] = fRow[a];
+ if(::basegfx::numeric::fTools::equalZero(fBig))
+ {
+ return sal_False;
+ }
- if(a2 >= 0)
- {
- for(b = a2; b < a; b++)
+ fStorage[a] = 1.0 / fBig;
+ }
+
+ // start normalizing
+ for(b = 0; b < RowSize; b++)
{
- fSum -= get(a, b) * fRow[b];
+ for(a = 0; a < b; a++)
+ {
+ fSum = get(a, b);
+
+ for(c = 0; c < a; c++)
+ {
+ fSum -= get(a, c) * get(c, b);
+ }
+
+ set(a, b, fSum);
+ }
+
+ fBig = 0.0;
+
+ for(a = b; a < RowSize; a++)
+ {
+ fSum = get(a, b);
+
+ for(c = 0; c < b; c++)
+ {
+ fSum -= get(a, c) * get(c, b);
+ }
+
+ set(a, b, fSum);
+ fDum = fStorage[a] * fabs(fSum);
+
+ if(::basegfx::numeric::fTools::moreOrEqual(fDum, fBig))
+ {
+ fBig = fDum;
+ nAMax = a;
+ }
+ }
+
+ if(b != nAMax)
+ {
+ for(c = 0; c < RowSize; c++)
+ {
+ fDum = get(nAMax, c);
+ set(nAMax, c, get(b, c));
+ set(b, c, fDum);
+ }
+
+ nParity = -nParity;
+ fStorage[nAMax] = fStorage[b];
+ }
+
+ nIndex[b] = nAMax;
+
+ // here the failure of precision occurs
+ const double fValBB(fabs(get(b, b)));
+
+ if(::basegfx::numeric::fTools::equalZero(fValBB))
+ {
+ return sal_False;
+ }
+
+ if(b != (RowSize - 1))
+ {
+ fDum = 1.0 / get(b, b);
+
+ for(a = b + 1; a < RowSize; a++)
+ {
+ set(a, b, get(a, b) * fDum);
+ }
+ }
}
+
+ return sal_True;
}
- else if(!::basegfx::numeric::fTools::equalZero(fSum))
+
+ void lubksb(const sal_uInt16 nIndex[], double fRow[]) const
{
- a2 = a;
- }
+ sal_uInt16 b, ip;
+ sal_Int16 a, a2 = -1;
+ double fSum;
- fRow[a] = fSum;
- }
+ for(a = 0; a < RowSize; a++)
+ {
+ ip = nIndex[a];
+ fSum = fRow[ip];
+ fRow[ip] = fRow[a];
+
+ if(a2 >= 0)
+ {
+ for(b = a2; b < a; b++)
+ {
+ fSum -= get(a, b) * fRow[b];
+ }
+ }
+ else if(!::basegfx::numeric::fTools::equalZero(fSum))
+ {
+ a2 = a;
+ }
+
+ fRow[a] = fSum;
+ }
- for(a = (RowSize - 1); a >= 0; a--)
- {
- fSum = fRow[a];
+ for(a = (RowSize - 1); a >= 0; a--)
+ {
+ fSum = fRow[a];
- for(b = a + 1; b < RowSize; b++)
- {
- fSum -= get(a, b) * fRow[b];
- }
+ for(b = a + 1; b < RowSize; b++)
+ {
+ fSum -= get(a, b) * fRow[b];
+ }
- const double fValueAA(get(a, a));
+ const double fValueAA(get(a, a));
- if(!::basegfx::numeric::fTools::equalZero(fValueAA))
- {
- fRow[a] = fSum / get(a, a);
+ if(!::basegfx::numeric::fTools::equalZero(fValueAA))
+ {
+ fRow[a] = fSum / get(a, a);
+ }
+ }
}
- }
- }
- sal_Bool isIdentity() const
- {
- // last line needs no testing if not existing
- const sal_uInt16 nMaxLine = (mpLine) ? RowSize : (RowSize - 1);
-
- for(sal_uInt16 a(0); a < nMaxLine; a++)
- {
- for(sal_uInt16 b(0); b < RowSize; b++)
+ sal_Bool isIdentity() const
{
- const double fDefault(implGetDefaultValue(a, b));
- const double fValueAB(get(a, b));
+ // last line needs no testing if not existing
+ const sal_uInt16 nMaxLine = (mpLine) ? RowSize : (RowSize - 1);
- if(!::basegfx::numeric::fTools::equal(fDefault, fValueAB))
+ for(sal_uInt16 a(0); a < nMaxLine; a++)
{
- return sal_False;
+ for(sal_uInt16 b(0); b < RowSize; b++)
+ {
+ const double fDefault(implGetDefaultValue(a, b));
+ const double fValueAB(get(a, b));
+
+ if(!::basegfx::numeric::fTools::equal(fDefault, fValueAB))
+ {
+ return sal_False;
+ }
+ }
}
- }
- }
-
- return sal_True;
- }
- sal_Bool isInvertible() const
- {
- ImplHomMatrixTemplate aWork(*this);
- sal_uInt16 nIndex[RowSize];
- sal_Int16 nParity;
-
- return aWork.ludcmp(nIndex, nParity);
- }
+ return sal_True;
+ }
- sal_Bool isNormalized() const
- {
- if(!mpLine)
- return sal_True;
+ sal_Bool isInvertible() const
+ {
+ ImplHomMatrixTemplate aWork(*this);
+ sal_uInt16 nIndex[RowSize];
+ sal_Int16 nParity;
- const double fHomValue(get((RowSize - 1), (RowSize - 1)));
+ return aWork.ludcmp(nIndex, nParity);
+ }
- if(::basegfx::numeric::fTools::equalZero(fHomValue))
- {
- return sal_True;
- }
+ sal_Bool isNormalized() const
+ {
+ if(!mpLine)
+ return sal_True;
- const double fOne(1.0);
+ const double fHomValue(get((RowSize - 1), (RowSize - 1)));
- if(::basegfx::numeric::fTools::equal(fOne, fHomValue))
- {
- return sal_True;
- }
+ if(::basegfx::numeric::fTools::equalZero(fHomValue))
+ {
+ return sal_True;
+ }
- return sal_False;
- }
+ const double fOne(1.0);
- void doInvert(const ImplHomMatrixTemplate& rWork, const sal_uInt16 nIndex[])
- {
- double fArray[RowSize];
+ if(::basegfx::numeric::fTools::equal(fOne, fHomValue))
+ {
+ return sal_True;
+ }
- for(sal_uInt16 a(0); a < RowSize; a++)
- {
- // prepare line
- for(sal_uInt16 b(0); b < RowSize; b++)
- {
- fArray[b] = implGetDefaultValue(a, b);
+ return sal_False;
}
- // expand line
- rWork.lubksb(nIndex, fArray);
-
- // copy line transposed to this matrix
- for(b = 0; b < RowSize; b++)
+ void doInvert(const ImplHomMatrixTemplate& rWork, const sal_uInt16 nIndex[])
{
- set(b, a, fArray[b]);
- }
- }
+ double fArray[RowSize];
- // evtl. get rid of last matrix line
- testLastLine();
- }
+ for(sal_uInt16 a(0); a < RowSize; a++)
+ {
+ // prepare line
+ for(sal_uInt16 b(0); b < RowSize; b++)
+ {
+ fArray[b] = implGetDefaultValue(a, b);
+ }
+
+ // expand line
+ rWork.lubksb(nIndex, fArray);
+
+ // copy line transposed to this matrix
+ for(b = 0; b < RowSize; b++)
+ {
+ set(b, a, fArray[b]);
+ }
+ }
- void doNormalize()
- {
- if(mpLine)
- {
- const double fHomValue(get((RowSize - 1), (RowSize - 1)));
+ // evtl. get rid of last matrix line
+ testLastLine();
+ }
- for(sal_uInt16 a(0); a < RowSize; a++)
+ void doNormalize()
{
- for(sal_uInt16 b(0); b < RowSize; b++)
+ if(mpLine)
{
- set(a, b, get(a, b) / fHomValue);
+ const double fHomValue(get((RowSize - 1), (RowSize - 1)));
+
+ for(sal_uInt16 a(0); a < RowSize; a++)
+ {
+ for(sal_uInt16 b(0); b < RowSize; b++)
+ {
+ set(a, b, get(a, b) / fHomValue);
+ }
+ }
+
+ // evtl. get rid of last matrix line
+ testLastLine();
}
}
- // evtl. get rid of last matrix line
- testLastLine();
- }
- }
+ double doDeterminant() const
+ {
+ ImplHomMatrixTemplate aWork(*this);
+ sal_uInt16 nIndex[RowSize];
+ sal_Int16 nParity;
+ double fRetval(0.0);
- double doDeterminant() const
- {
- ImplHomMatrixTemplate aWork(*this);
- sal_uInt16 nIndex[RowSize];
- sal_Int16 nParity;
- double fRetval(0.0);
+ if(aWork.ludcmp(nIndex, nParity))
+ {
+ fRetval = (double)nParity;
- if(aWork.ludcmp(nIndex, nParity))
- {
- fRetval = (double)nParity;
+ // last line needs no multiply if not existing; default value would be 1.
+ const sal_uInt16 nMaxLine = (aWork.mpLine) ? RowSize : (RowSize - 1);
- // last line needs no multiply if not existing; default value would be 1.
- const sal_uInt16 nMaxLine = (aWork.mpLine) ? RowSize : (RowSize - 1);
+ for(sal_uInt16 a(0); a < nMaxLine; a++)
+ {
+ fRetval *= aWork.get(a, a);
+ }
+ }
- for(sal_uInt16 a(0); a < nMaxLine; a++)
- {
- fRetval *= aWork.get(a, a);
+ return fRetval;
}
- }
-
- return fRetval;
- }
- double doTrace() const
- {
- double fTrace = (mpLine) ? 0.0 : 1.0;
- const sal_uInt16 nMaxLine = (mpLine) ? RowSize : (RowSize - 1);
+ double doTrace() const
+ {
+ double fTrace = (mpLine) ? 0.0 : 1.0;
+ const sal_uInt16 nMaxLine = (mpLine) ? RowSize : (RowSize - 1);
- for(sal_uInt16 a(0); a < nMaxLine; a++)
- {
- fTrace += get(a, a);
- }
+ for(sal_uInt16 a(0); a < nMaxLine; a++)
+ {
+ fTrace += get(a, a);
+ }
- return fTrace;
- }
+ return fTrace;
+ }
- void doTranspose()
- {
- for(sal_uInt16 a(0); a < (RowSize - 1); a++)
- {
- for(sal_uInt16 b(a + 1); b < RowSize; b++)
+ void doTranspose()
{
- const double fTemp(get(a, b));
- set(a, b, get(b, a));
- set(b, a, fTemp);
- }
- }
+ for(sal_uInt16 a(0); a < (RowSize - 1); a++)
+ {
+ for(sal_uInt16 b(a + 1); b < RowSize; b++)
+ {
+ const double fTemp(get(a, b));
+ set(a, b, get(b, a));
+ set(b, a, fTemp);
+ }
+ }
- testLastLine();
- }
+ testLastLine();
+ }
- void doAddMatrix(const ImplHomMatrixTemplate& rMat)
- {
- for(sal_uInt16 a(0); a < RowSize; a++)
- {
- for(sal_uInt16 b(0); b < RowSize; b++)
+ void doAddMatrix(const ImplHomMatrixTemplate& rMat)
{
- set(a, b, get(a, b) + rMat.get(a, b));
- }
- }
+ for(sal_uInt16 a(0); a < RowSize; a++)
+ {
+ for(sal_uInt16 b(0); b < RowSize; b++)
+ {
+ set(a, b, get(a, b) + rMat.get(a, b));
+ }
+ }
- testLastLine();
- }
+ testLastLine();
+ }
- void doSubMatrix(const ImplHomMatrixTemplate& rMat)
- {
- for(sal_uInt16 a(0); a < RowSize; a++)
- {
- for(sal_uInt16 b(0); b < RowSize; b++)
+ void doSubMatrix(const ImplHomMatrixTemplate& rMat)
{
- set(a, b, get(a, b) - rMat.get(a, b));
- }
- }
+ for(sal_uInt16 a(0); a < RowSize; a++)
+ {
+ for(sal_uInt16 b(0); b < RowSize; b++)
+ {
+ set(a, b, get(a, b) - rMat.get(a, b));
+ }
+ }
- testLastLine();
- }
+ testLastLine();
+ }
- void doMulMatrix(const double& rfValue)
- {
- for(sal_uInt16 a(0); a < RowSize; a++)
- {
- for(sal_uInt16 b(0); b < RowSize; b++)
+ void doMulMatrix(const double& rfValue)
{
- set(a, b, get(a, b) * rfValue);
+ for(sal_uInt16 a(0); a < RowSize; a++)
+ {
+ for(sal_uInt16 b(0); b < RowSize; b++)
+ {
+ set(a, b, get(a, b) * rfValue);
+ }
+ }
+
+ testLastLine();
}
- }
- testLastLine();
- }
+ void doMulMatrix(const ImplHomMatrixTemplate& rMat)
+ {
+ // create a copy as source for the original values
+ const ImplHomMatrixTemplate aCopy(*this);
- void doMulMatrix(const ImplHomMatrixTemplate& rMat)
- {
- // create a copy as source for the original values
- const ImplHomMatrixTemplate aCopy(*this);
+ // TODO: maybe optimize cases where last line is [0 0 1].
- // TODO: maybe optimize cases where last line is [0 0 1].
+ double fValue(0.0);
- double fValue(0.0);
+ for(sal_uInt16 a(0); a < RowSize; ++a)
+ {
+ for(sal_uInt16 b(0); b < RowSize; ++b)
+ {
+ fValue = 0.0;
- for(sal_uInt16 a(0); a < RowSize; ++a)
- {
- for(sal_uInt16 b(0); b < RowSize; ++b)
- {
- fValue = 0.0;
+ for(sal_uInt16 c(0); c < RowSize; ++c)
+ fValue += aCopy.get(c, b) * rMat.get(a, c);
- for(sal_uInt16 c(0); c < RowSize; ++c)
- fValue += aCopy.get(c, b) * rMat.get(a, c);
+ set(a, b, fValue);
+ }
+ }
- set(a, b, fValue);
+ testLastLine();
}
- }
- testLastLine();
- }
-
- sal_Bool isEqual(const ImplHomMatrixTemplate& rMat)
- {
- const sal_uInt16 nMaxLine = (mpLine || rMat.mpLine) ? RowSize : (RowSize - 1);
-
- for(sal_uInt16 a(0); a < nMaxLine; a++)
- {
- for(sal_uInt16 b(0); b < RowSize; b++)
+ sal_Bool isEqual(const ImplHomMatrixTemplate& rMat)
{
- const double fValueA(get(a, b));
- const double fValueB(rMat.get(a, b));
+ const sal_uInt16 nMaxLine = (mpLine || rMat.mpLine) ? RowSize : (RowSize - 1);
- if(!::basegfx::numeric::fTools::equal(fValueA, fValueB))
+ for(sal_uInt16 a(0); a < nMaxLine; a++)
{
- return sal_False;
+ for(sal_uInt16 b(0); b < RowSize; b++)
+ {
+ const double fValueA(get(a, b));
+ const double fValueB(rMat.get(a, b));
+
+ if(!::basegfx::numeric::fTools::equal(fValueA, fValueB))
+ {
+ return sal_False;
+ }
+ }
}
+
+ return sal_True;
}
- }
+ };
- return sal_True;
- }
-};
+ } // namespace internal
+} // namespace basegfx
#endif // _HOMMATRIX_TEMPLATE_HXX
diff --git a/basegfx/source/matrix/b2dhommatrix.cxx b/basegfx/source/matrix/b2dhommatrix.cxx
index f9b4b3e48554..d2175b502db3 100644
--- a/basegfx/source/matrix/b2dhommatrix.cxx
+++ b/basegfx/source/matrix/b2dhommatrix.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dhommatrix.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:51 $
+ * last change: $Author: thb $ $Date: 2003-11-10 15:10:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -79,20 +79,20 @@
#include <basegfx/tuple/b2dtuple.hxx>
#endif
-class Impl2DHomMatrix : public ImplHomMatrixTemplate< 3 >
-{
-};
-
-static Impl2DHomMatrix& get2DIdentityMatrix()
-{
- static Impl2DHomMatrix maStatic2DIdentityHomMatrix;
- return maStatic2DIdentityHomMatrix;
-}
-
namespace basegfx
{
namespace matrix
{
+ class Impl2DHomMatrix : public ::basegfx::internal::ImplHomMatrixTemplate< 3 >
+ {
+ };
+
+ static Impl2DHomMatrix& get2DIdentityMatrix()
+ {
+ static Impl2DHomMatrix maStatic2DIdentityHomMatrix;
+ return maStatic2DIdentityHomMatrix;
+ }
+
void B2DHomMatrix::implPrepareChange()
{
if(mpM->getRefCount())
diff --git a/basegfx/source/matrix/b3dhommatrix.cxx b/basegfx/source/matrix/b3dhommatrix.cxx
index 232ff46c7c77..dee47579741f 100644
--- a/basegfx/source/matrix/b3dhommatrix.cxx
+++ b/basegfx/source/matrix/b3dhommatrix.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3dhommatrix.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:52 $
+ * last change: $Author: thb $ $Date: 2003-11-10 15:10:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,20 +71,20 @@
#include <basegfx/vector/b3dvector.hxx>
#endif
-class Impl3DHomMatrix : public ImplHomMatrixTemplate< 4 >
-{
-};
-
-static Impl3DHomMatrix& get3DIdentityMatrix()
-{
- static Impl3DHomMatrix maStatic3DIdentityHomMatrix;
- return maStatic3DIdentityHomMatrix;
-}
-
namespace basegfx
{
namespace matrix
{
+ class Impl3DHomMatrix : public ::basegfx::internal::ImplHomMatrixTemplate< 4 >
+ {
+ };
+
+ static Impl3DHomMatrix& get3DIdentityMatrix()
+ {
+ static Impl3DHomMatrix maStatic3DIdentityHomMatrix;
+ return maStatic3DIdentityHomMatrix;
+ }
+
void B3DHomMatrix::implPrepareChange()
{
if(mpM->getRefCount())