summaryrefslogtreecommitdiff
path: root/basegfx/source/matrix
diff options
context:
space:
mode:
Diffstat (limited to 'basegfx/source/matrix')
-rw-r--r--basegfx/source/matrix/b2dhommatrix.cxx493
-rw-r--r--basegfx/source/matrix/b3dhommatrix.cxx861
2 files changed, 674 insertions, 680 deletions
diff --git a/basegfx/source/matrix/b2dhommatrix.cxx b/basegfx/source/matrix/b2dhommatrix.cxx
index d2175b502db3..ae36adfd72f9 100644
--- a/basegfx/source/matrix/b2dhommatrix.cxx
+++ b/basegfx/source/matrix/b2dhommatrix.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dhommatrix.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: thb $ $Date: 2003-11-10 15:10:57 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -81,336 +81,333 @@
namespace basegfx
{
- namespace matrix
+ class Impl2DHomMatrix : public ::basegfx::internal::ImplHomMatrixTemplate< 3 >
{
- class Impl2DHomMatrix : public ::basegfx::internal::ImplHomMatrixTemplate< 3 >
- {
- };
+ };
- static Impl2DHomMatrix& get2DIdentityMatrix()
- {
- static Impl2DHomMatrix maStatic2DIdentityHomMatrix;
- return maStatic2DIdentityHomMatrix;
- }
+ static Impl2DHomMatrix& get2DIdentityMatrix()
+ {
+ static Impl2DHomMatrix maStatic2DIdentityHomMatrix;
+ return maStatic2DIdentityHomMatrix;
+ }
- void B2DHomMatrix::implPrepareChange()
+ void B2DHomMatrix::implPrepareChange()
+ {
+ if(mpM->getRefCount())
{
- if(mpM->getRefCount())
- {
- mpM->decRefCount();
- mpM = new Impl2DHomMatrix(*mpM);
- }
+ mpM->decRefCount();
+ mpM = new Impl2DHomMatrix(*mpM);
}
+ }
- B2DHomMatrix::B2DHomMatrix()
- : mpM(&get2DIdentityMatrix())
- {
- mpM->incRefCount();
- }
+ B2DHomMatrix::B2DHomMatrix()
+ : mpM(&get2DIdentityMatrix())
+ {
+ mpM->incRefCount();
+ }
- B2DHomMatrix::B2DHomMatrix(const B2DHomMatrix& rMat)
- : mpM(rMat.mpM)
- {
- mpM->incRefCount();
- }
+ B2DHomMatrix::B2DHomMatrix(const B2DHomMatrix& rMat)
+ : mpM(rMat.mpM)
+ {
+ mpM->incRefCount();
+ }
- B2DHomMatrix::~B2DHomMatrix()
- {
- if(mpM->getRefCount())
- mpM->decRefCount();
- else
- delete mpM;
- }
+ B2DHomMatrix::~B2DHomMatrix()
+ {
+ if(mpM->getRefCount())
+ mpM->decRefCount();
+ else
+ delete mpM;
+ }
- B2DHomMatrix& B2DHomMatrix::operator=(const B2DHomMatrix& rMat)
- {
- if(mpM->getRefCount())
- mpM->decRefCount();
- else
- delete mpM;
+ B2DHomMatrix& B2DHomMatrix::operator=(const B2DHomMatrix& rMat)
+ {
+ if(mpM->getRefCount())
+ mpM->decRefCount();
+ else
+ delete mpM;
- mpM = rMat.mpM;
- mpM->incRefCount();
+ mpM = rMat.mpM;
+ mpM->incRefCount();
- return *this;
- }
+ return *this;
+ }
- double B2DHomMatrix::get(sal_uInt16 nRow, sal_uInt16 nColumn) const
- {
- return mpM->get(nRow, nColumn);
- }
+ double B2DHomMatrix::get(sal_uInt16 nRow, sal_uInt16 nColumn) const
+ {
+ return mpM->get(nRow, nColumn);
+ }
- void B2DHomMatrix::set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
- {
- implPrepareChange();
- mpM->set(nRow, nColumn, fValue);
- }
+ void B2DHomMatrix::set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
+ {
+ implPrepareChange();
+ mpM->set(nRow, nColumn, fValue);
+ }
- sal_Bool B2DHomMatrix::isIdentity() const
- {
- if(mpM == &get2DIdentityMatrix())
- return sal_True;
+ sal_Bool B2DHomMatrix::isIdentity() const
+ {
+ if(mpM == &get2DIdentityMatrix())
+ return sal_True;
- return mpM->isIdentity();
- }
+ return mpM->isIdentity();
+ }
- void B2DHomMatrix::identity()
+ void B2DHomMatrix::identity()
+ {
+ if(mpM->getRefCount())
+ mpM->decRefCount();
+ else
+ delete mpM;
+
+ mpM = &get2DIdentityMatrix();
+ mpM->incRefCount();
+ }
+
+ sal_Bool B2DHomMatrix::isInvertible() const
+ {
+ return mpM->isInvertible();
+ }
+
+ sal_Bool B2DHomMatrix::invert()
+ {
+ Impl2DHomMatrix aWork(*mpM);
+ sal_uInt16* pIndex = new sal_uInt16[mpM->getEdgeLength()];
+ sal_Int16 nParity;
+
+ if(aWork.ludcmp(pIndex, nParity))
{
- if(mpM->getRefCount())
- mpM->decRefCount();
- else
- delete mpM;
+ implPrepareChange();
+ mpM->doInvert(aWork, pIndex);
+ delete pIndex;
- mpM = &get2DIdentityMatrix();
- mpM->incRefCount();
+ return sal_True;
}
- sal_Bool B2DHomMatrix::isInvertible() const
+ delete pIndex;
+ return sal_False;
+ }
+
+ sal_Bool B2DHomMatrix::isNormalized() const
+ {
+ return mpM->isNormalized();
+ }
+
+ void B2DHomMatrix::normalize()
+ {
+ if(!mpM->isNormalized())
{
- return mpM->isInvertible();
+ implPrepareChange();
+ mpM->doNormalize();
}
+ }
- sal_Bool B2DHomMatrix::invert()
- {
- Impl2DHomMatrix aWork(*mpM);
- sal_uInt16* pIndex = new sal_uInt16[mpM->getEdgeLength()];
- sal_Int16 nParity;
+ double B2DHomMatrix::determinant() const
+ {
+ return mpM->doDeterminant();
+ }
- if(aWork.ludcmp(pIndex, nParity))
- {
- implPrepareChange();
- mpM->doInvert(aWork, pIndex);
- delete pIndex;
+ double B2DHomMatrix::trace() const
+ {
+ return mpM->doTrace();
+ }
- return sal_True;
- }
+ void B2DHomMatrix::transpose()
+ {
+ implPrepareChange();
+ mpM->doTranspose();
+ }
- delete pIndex;
- return sal_False;
- }
+ B2DHomMatrix& B2DHomMatrix::operator+=(const B2DHomMatrix& rMat)
+ {
+ implPrepareChange();
+ mpM->doAddMatrix(*rMat.mpM);
- sal_Bool B2DHomMatrix::isNormalized() const
- {
- return mpM->isNormalized();
- }
+ return *this;
+ }
- void B2DHomMatrix::normalize()
- {
- if(!mpM->isNormalized())
- {
- implPrepareChange();
- mpM->doNormalize();
- }
- }
+ B2DHomMatrix& B2DHomMatrix::operator-=(const B2DHomMatrix& rMat)
+ {
+ implPrepareChange();
+ mpM->doSubMatrix(*rMat.mpM);
- double B2DHomMatrix::determinant() const
- {
- return mpM->doDeterminant();
- }
+ return *this;
+ }
- double B2DHomMatrix::trace() const
- {
- return mpM->doTrace();
- }
+ B2DHomMatrix& B2DHomMatrix::operator*=(double fValue)
+ {
+ const double fOne(1.0);
- void B2DHomMatrix::transpose()
+ if(!::basegfx::fTools::equal(fOne, fValue))
{
implPrepareChange();
- mpM->doTranspose();
+ mpM->doMulMatrix(fValue);
}
- B2DHomMatrix& B2DHomMatrix::operator+=(const B2DHomMatrix& rMat)
- {
- implPrepareChange();
- mpM->doAddMatrix(*rMat.mpM);
+ return *this;
+ }
- return *this;
- }
+ B2DHomMatrix& B2DHomMatrix::operator/=(double fValue)
+ {
+ const double fOne(1.0);
- B2DHomMatrix& B2DHomMatrix::operator-=(const B2DHomMatrix& rMat)
+ if(!::basegfx::fTools::equal(fOne, fValue))
{
implPrepareChange();
- mpM->doSubMatrix(*rMat.mpM);
-
- return *this;
+ mpM->doMulMatrix(1.0 / fValue);
}
- B2DHomMatrix& B2DHomMatrix::operator*=(double fValue)
- {
- const double fOne(1.0);
-
- if(!::basegfx::numeric::fTools::equal(fOne, fValue))
- {
- implPrepareChange();
- mpM->doMulMatrix(fValue);
- }
+ return *this;
+ }
- return *this;
- }
-
- B2DHomMatrix& B2DHomMatrix::operator/=(double fValue)
+ B2DHomMatrix& B2DHomMatrix::operator*=(const B2DHomMatrix& rMat)
+ {
+ if(!rMat.isIdentity())
{
- const double fOne(1.0);
-
- if(!::basegfx::numeric::fTools::equal(fOne, fValue))
- {
- implPrepareChange();
- mpM->doMulMatrix(1.0 / fValue);
- }
-
- return *this;
+ implPrepareChange();
+ mpM->doMulMatrix(*rMat.mpM);
}
- B2DHomMatrix& B2DHomMatrix::operator*=(const B2DHomMatrix& rMat)
- {
- if(!rMat.isIdentity())
- {
- implPrepareChange();
- mpM->doMulMatrix(*rMat.mpM);
- }
+ return *this;
+ }
- return *this;
- }
+ sal_Bool B2DHomMatrix::operator==(const B2DHomMatrix& rMat) const
+ {
+ if(mpM == rMat.mpM)
+ return sal_True;
- sal_Bool B2DHomMatrix::operator==(const B2DHomMatrix& rMat) const
- {
- if(mpM == rMat.mpM)
- return sal_True;
+ return mpM->isEqual(*rMat.mpM);
+ }
- return mpM->isEqual(*rMat.mpM);
- }
+ sal_Bool B2DHomMatrix::operator!=(const B2DHomMatrix& rMat) const
+ {
+ if(mpM == rMat.mpM)
+ return sal_False;
+
+ return !mpM->isEqual(*rMat.mpM);
+ }
- sal_Bool B2DHomMatrix::operator!=(const B2DHomMatrix& rMat) const
+ void B2DHomMatrix::rotate(double fRadiant)
+ {
+ if(!::basegfx::fTools::equalZero(fRadiant))
{
- if(mpM == rMat.mpM)
- return sal_False;
+ Impl2DHomMatrix aRotMat(get2DIdentityMatrix());
+ double fSin(sin(fRadiant));
+ double fCos(cos(fRadiant));
- return !mpM->isEqual(*rMat.mpM);
- }
+ aRotMat.set(0, 0, fCos);
+ aRotMat.set(1, 1, fCos);
+ aRotMat.set(1, 0, fSin);
+ aRotMat.set(0, 1, -fSin);
- void B2DHomMatrix::rotate(double fRadiant)
- {
- if(!::basegfx::numeric::fTools::equalZero(fRadiant))
- {
- Impl2DHomMatrix aRotMat(get2DIdentityMatrix());
- double fSin(sin(fRadiant));
- double fCos(cos(fRadiant));
-
- aRotMat.set(0, 0, fCos);
- aRotMat.set(1, 1, fCos);
- aRotMat.set(1, 0, fSin);
- aRotMat.set(0, 1, -fSin);
-
- implPrepareChange();
- mpM->doMulMatrix(aRotMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aRotMat);
}
+ }
- void B2DHomMatrix::translate(double fX, double fY)
+ void B2DHomMatrix::translate(double fX, double fY)
+ {
+ if(!::basegfx::fTools::equalZero(fX) || !::basegfx::fTools::equalZero(fY))
{
- if(!::basegfx::numeric::fTools::equalZero(fX) || !::basegfx::numeric::fTools::equalZero(fY))
- {
- Impl2DHomMatrix aTransMat(get2DIdentityMatrix());
+ Impl2DHomMatrix aTransMat(get2DIdentityMatrix());
- aTransMat.set(0, 2, fX);
- aTransMat.set(1, 2, fY);
+ aTransMat.set(0, 2, fX);
+ aTransMat.set(1, 2, fY);
- implPrepareChange();
- mpM->doMulMatrix(aTransMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aTransMat);
}
+ }
- void B2DHomMatrix::scale(double fX, double fY)
- {
- const double fOne(1.0);
+ void B2DHomMatrix::scale(double fX, double fY)
+ {
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equal(fOne, fX) || !::basegfx::numeric::fTools::equal(fOne, fY))
- {
- Impl2DHomMatrix aScaleMat(get2DIdentityMatrix());
+ if(!::basegfx::fTools::equal(fOne, fX) || !::basegfx::fTools::equal(fOne, fY))
+ {
+ Impl2DHomMatrix aScaleMat(get2DIdentityMatrix());
- aScaleMat.set(0, 0, fX);
- aScaleMat.set(1, 1, fY);
+ aScaleMat.set(0, 0, fX);
+ aScaleMat.set(1, 1, fY);
- implPrepareChange();
- mpM->doMulMatrix(aScaleMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aScaleMat);
}
+ }
- void B2DHomMatrix::shearX(double fSx)
- {
- const double fOne(1.0);
+ void B2DHomMatrix::shearX(double fSx)
+ {
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equal(fOne, fSx))
- {
- Impl2DHomMatrix aShearXMat(get2DIdentityMatrix());
+ if(!::basegfx::fTools::equal(fOne, fSx))
+ {
+ Impl2DHomMatrix aShearXMat(get2DIdentityMatrix());
- aShearXMat.set(0, 1, fSx);
+ aShearXMat.set(0, 1, fSx);
- implPrepareChange();
- mpM->doMulMatrix(aShearXMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aShearXMat);
}
+ }
- void B2DHomMatrix::shearY(double fSy)
- {
- const double fOne(1.0);
+ void B2DHomMatrix::shearY(double fSy)
+ {
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equal(fOne, fSy))
- {
- Impl2DHomMatrix aShearYMat(get2DIdentityMatrix());
+ if(!::basegfx::fTools::equal(fOne, fSy))
+ {
+ Impl2DHomMatrix aShearYMat(get2DIdentityMatrix());
- aShearYMat.set(1, 0, fSy);
+ aShearYMat.set(1, 0, fSy);
- implPrepareChange();
- mpM->doMulMatrix(aShearYMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aShearYMat);
}
+ }
- // Decomposition
- sal_Bool B2DHomMatrix::decompose(tuple::B2DTuple& rScale, tuple::B2DTuple& rTranslate, double& rRotate, double& rShearX) const
- {
- // when perspective is used, decompose is not made here
- if(!mpM->isLastLineDefault())
- return sal_False;
-
- // If determinant is zero, decomposition is not possible
- if(0.0 == mpM->doDeterminant())
- return sal_False;
+ // Decomposition
+ sal_Bool B2DHomMatrix::decompose(B2DTuple& rScale, B2DTuple& rTranslate, double& rRotate, double& rShearX) const
+ {
+ // when perspective is used, decompose is not made here
+ if(!mpM->isLastLineDefault())
+ return sal_False;
- // copy 2x2 matrix and translate vector to 3x3 matrix
- ::basegfx::matrix::B3DHomMatrix a3DHomMat;
+ // If determinant is zero, decomposition is not possible
+ if(0.0 == mpM->doDeterminant())
+ return sal_False;
- a3DHomMat.set(0, 0, get(0, 0));
- a3DHomMat.set(0, 1, get(0, 1));
- a3DHomMat.set(1, 0, get(1, 0));
- a3DHomMat.set(1, 1, get(1, 1));
- a3DHomMat.set(0, 2, get(0, 3));
- a3DHomMat.set(1, 2, get(1, 3));
+ // copy 2x2 matrix and translate vector to 3x3 matrix
+ ::basegfx::B3DHomMatrix a3DHomMat;
- ::basegfx::tuple::B3DTuple r3DScale, r3DTranslate, r3DRotate, r3DShear;
+ a3DHomMat.set(0, 0, get(0, 0));
+ a3DHomMat.set(0, 1, get(0, 1));
+ a3DHomMat.set(1, 0, get(1, 0));
+ a3DHomMat.set(1, 1, get(1, 1));
+ a3DHomMat.set(0, 2, get(0, 3));
+ a3DHomMat.set(1, 2, get(1, 3));
- if(a3DHomMat.decompose(r3DScale, r3DTranslate, r3DRotate, r3DShear))
- {
- // copy scale values
- rScale.setX(r3DScale.getX());
- rScale.setY(r3DScale.getY());
+ ::basegfx::B3DTuple r3DScale, r3DTranslate, r3DRotate, r3DShear;
- // copy shear
- rShearX = r3DShear.getX();
+ if(a3DHomMat.decompose(r3DScale, r3DTranslate, r3DRotate, r3DShear))
+ {
+ // copy scale values
+ rScale.setX(r3DScale.getX());
+ rScale.setY(r3DScale.getY());
- // copy rotate
- rRotate = r3DRotate.getZ();
+ // copy shear
+ rShearX = r3DShear.getX();
- // copy translate
- rTranslate.setX(r3DTranslate.getX());
- rTranslate.setY(r3DTranslate.getY());
+ // copy rotate
+ rRotate = r3DRotate.getZ();
- return sal_True;
- }
+ // copy translate
+ rTranslate.setX(r3DTranslate.getX());
+ rTranslate.setY(r3DTranslate.getY());
- return sal_False;
+ return sal_True;
}
- } // end of namespace matrix
+
+ return sal_False;
+ }
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/matrix/b3dhommatrix.cxx b/basegfx/source/matrix/b3dhommatrix.cxx
index dee47579741f..b6df9ff51767 100644
--- a/basegfx/source/matrix/b3dhommatrix.cxx
+++ b/basegfx/source/matrix/b3dhommatrix.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3dhommatrix.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: thb $ $Date: 2003-11-10 15:10:57 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,567 +73,564 @@
namespace basegfx
{
- namespace matrix
+ class Impl3DHomMatrix : public ::basegfx::internal::ImplHomMatrixTemplate< 4 >
{
- class Impl3DHomMatrix : public ::basegfx::internal::ImplHomMatrixTemplate< 4 >
- {
- };
+ };
- static Impl3DHomMatrix& get3DIdentityMatrix()
- {
- static Impl3DHomMatrix maStatic3DIdentityHomMatrix;
- return maStatic3DIdentityHomMatrix;
- }
+ static Impl3DHomMatrix& get3DIdentityMatrix()
+ {
+ static Impl3DHomMatrix maStatic3DIdentityHomMatrix;
+ return maStatic3DIdentityHomMatrix;
+ }
- void B3DHomMatrix::implPrepareChange()
+ void B3DHomMatrix::implPrepareChange()
+ {
+ if(mpM->getRefCount())
{
- if(mpM->getRefCount())
- {
- mpM->decRefCount();
- mpM = new Impl3DHomMatrix(*mpM);
- }
+ mpM->decRefCount();
+ mpM = new Impl3DHomMatrix(*mpM);
}
+ }
- B3DHomMatrix::B3DHomMatrix()
- : mpM(&get3DIdentityMatrix())
- {
- mpM->incRefCount();
- }
+ B3DHomMatrix::B3DHomMatrix()
+ : mpM(&get3DIdentityMatrix())
+ {
+ mpM->incRefCount();
+ }
- B3DHomMatrix::B3DHomMatrix(const B3DHomMatrix& rMat)
- : mpM(rMat.mpM)
- {
- mpM->incRefCount();
- }
+ B3DHomMatrix::B3DHomMatrix(const B3DHomMatrix& rMat)
+ : mpM(rMat.mpM)
+ {
+ mpM->incRefCount();
+ }
- B3DHomMatrix::~B3DHomMatrix()
- {
- if(mpM->getRefCount())
- mpM->decRefCount();
- else
- delete mpM;
- }
+ B3DHomMatrix::~B3DHomMatrix()
+ {
+ if(mpM->getRefCount())
+ mpM->decRefCount();
+ else
+ delete mpM;
+ }
- B3DHomMatrix& B3DHomMatrix::operator=(const B3DHomMatrix& rMat)
- {
- if(mpM->getRefCount())
- mpM->decRefCount();
- else
- delete mpM;
+ B3DHomMatrix& B3DHomMatrix::operator=(const B3DHomMatrix& rMat)
+ {
+ if(mpM->getRefCount())
+ mpM->decRefCount();
+ else
+ delete mpM;
- mpM = rMat.mpM;
- mpM->incRefCount();
+ mpM = rMat.mpM;
+ mpM->incRefCount();
- return *this;
- }
+ return *this;
+ }
- double B3DHomMatrix::get(sal_uInt16 nRow, sal_uInt16 nColumn) const
- {
- return mpM->get(nRow, nColumn);
- }
+ double B3DHomMatrix::get(sal_uInt16 nRow, sal_uInt16 nColumn) const
+ {
+ return mpM->get(nRow, nColumn);
+ }
- void B3DHomMatrix::set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
- {
- implPrepareChange();
- mpM->set(nRow, nColumn, fValue);
- }
+ void B3DHomMatrix::set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
+ {
+ implPrepareChange();
+ mpM->set(nRow, nColumn, fValue);
+ }
- sal_Bool B3DHomMatrix::isIdentity() const
- {
- if(mpM == &get3DIdentityMatrix())
- return sal_True;
+ sal_Bool B3DHomMatrix::isIdentity() const
+ {
+ if(mpM == &get3DIdentityMatrix())
+ return sal_True;
- return mpM->isIdentity();
- }
+ return mpM->isIdentity();
+ }
+
+ void B3DHomMatrix::identity()
+ {
+ if(mpM->getRefCount())
+ mpM->decRefCount();
+ else
+ delete mpM;
+
+ mpM = &get3DIdentityMatrix();
+ mpM->incRefCount();
+ }
+
+ sal_Bool B3DHomMatrix::isInvertible() const
+ {
+ return mpM->isInvertible();
+ }
+
+ sal_Bool B3DHomMatrix::invert()
+ {
+ Impl3DHomMatrix aWork(*mpM);
+ sal_uInt16* pIndex = new sal_uInt16[mpM->getEdgeLength()];
+ sal_Int16 nParity;
- void B3DHomMatrix::identity()
+ if(aWork.ludcmp(pIndex, nParity))
{
- if(mpM->getRefCount())
- mpM->decRefCount();
- else
- delete mpM;
+ implPrepareChange();
+ mpM->doInvert(aWork, pIndex);
+ delete pIndex;
- mpM = &get3DIdentityMatrix();
- mpM->incRefCount();
+ return sal_True;
}
- sal_Bool B3DHomMatrix::isInvertible() const
+ delete pIndex;
+ return sal_False;
+ }
+
+ sal_Bool B3DHomMatrix::isNormalized() const
+ {
+ return mpM->isNormalized();
+ }
+
+ void B3DHomMatrix::normalize()
+ {
+ if(!mpM->isNormalized())
{
- return mpM->isInvertible();
+ implPrepareChange();
+ mpM->doNormalize();
}
+ }
- sal_Bool B3DHomMatrix::invert()
- {
- Impl3DHomMatrix aWork(*mpM);
- sal_uInt16* pIndex = new sal_uInt16[mpM->getEdgeLength()];
- sal_Int16 nParity;
+ double B3DHomMatrix::determinant() const
+ {
+ return mpM->doDeterminant();
+ }
- if(aWork.ludcmp(pIndex, nParity))
- {
- implPrepareChange();
- mpM->doInvert(aWork, pIndex);
- delete pIndex;
+ double B3DHomMatrix::trace() const
+ {
+ return mpM->doTrace();
+ }
- return sal_True;
- }
+ void B3DHomMatrix::transpose()
+ {
+ implPrepareChange();
+ mpM->doTranspose();
+ }
- delete pIndex;
- return sal_False;
- }
+ B3DHomMatrix& B3DHomMatrix::operator+=(const B3DHomMatrix& rMat)
+ {
+ implPrepareChange();
+ mpM->doAddMatrix(*rMat.mpM);
- sal_Bool B3DHomMatrix::isNormalized() const
- {
- return mpM->isNormalized();
- }
+ return *this;
+ }
- void B3DHomMatrix::normalize()
- {
- if(!mpM->isNormalized())
- {
- implPrepareChange();
- mpM->doNormalize();
- }
- }
+ B3DHomMatrix& B3DHomMatrix::operator-=(const B3DHomMatrix& rMat)
+ {
+ implPrepareChange();
+ mpM->doSubMatrix(*rMat.mpM);
- double B3DHomMatrix::determinant() const
- {
- return mpM->doDeterminant();
- }
+ return *this;
+ }
- double B3DHomMatrix::trace() const
- {
- return mpM->doTrace();
- }
+ B3DHomMatrix& B3DHomMatrix::operator*=(double fValue)
+ {
+ const double fOne(1.0);
- void B3DHomMatrix::transpose()
+ if(!::basegfx::fTools::equal(fOne, fValue))
{
implPrepareChange();
- mpM->doTranspose();
+ mpM->doMulMatrix(fValue);
}
- B3DHomMatrix& B3DHomMatrix::operator+=(const B3DHomMatrix& rMat)
+ return *this;
+ }
+
+ B3DHomMatrix& B3DHomMatrix::operator/=(double fValue)
+ {
+ const double fOne(1.0);
+
+ if(!::basegfx::fTools::equal(fOne, fValue))
{
implPrepareChange();
- mpM->doAddMatrix(*rMat.mpM);
-
- return *this;
+ mpM->doMulMatrix(1.0 / fValue);
}
- B3DHomMatrix& B3DHomMatrix::operator-=(const B3DHomMatrix& rMat)
+ return *this;
+ }
+
+ B3DHomMatrix& B3DHomMatrix::operator*=(const B3DHomMatrix& rMat)
+ {
+ if(!rMat.isIdentity())
{
implPrepareChange();
- mpM->doSubMatrix(*rMat.mpM);
-
- return *this;
+ mpM->doMulMatrix(*rMat.mpM);
}
- B3DHomMatrix& B3DHomMatrix::operator*=(double fValue)
- {
- const double fOne(1.0);
+ return *this;
+ }
- if(!::basegfx::numeric::fTools::equal(fOne, fValue))
- {
- implPrepareChange();
- mpM->doMulMatrix(fValue);
- }
+ sal_Bool B3DHomMatrix::operator==(const B3DHomMatrix& rMat) const
+ {
+ if(mpM == rMat.mpM)
+ return sal_True;
- return *this;
- }
+ return mpM->isEqual(*rMat.mpM);
+ }
+
+ sal_Bool B3DHomMatrix::operator!=(const B3DHomMatrix& rMat) const
+ {
+ if(mpM == rMat.mpM)
+ return sal_False;
- B3DHomMatrix& B3DHomMatrix::operator/=(double fValue)
+ return !mpM->isEqual(*rMat.mpM);
+ }
+
+ void B3DHomMatrix::rotate(double fAngleX,double fAngleY,double fAngleZ)
+ {
+ if(!::basegfx::fTools::equalZero(fAngleX) || !::basegfx::fTools::equalZero(fAngleY) || !::basegfx::fTools::equalZero(fAngleZ))
{
- const double fOne(1.0);
+ implPrepareChange();
- if(!::basegfx::numeric::fTools::equal(fOne, fValue))
+ if(!::basegfx::fTools::equalZero(fAngleX))
{
- implPrepareChange();
- mpM->doMulMatrix(1.0 / fValue);
- }
+ Impl3DHomMatrix aRotMatX(get3DIdentityMatrix());
+ double fSin(sin(fAngleX));
+ double fCos(cos(fAngleX));
- return *this;
- }
+ aRotMatX.set(1, 1, fCos);
+ aRotMatX.set(2, 2, fCos);
+ aRotMatX.set(2, 1, fSin);
+ aRotMatX.set(1, 2, -fSin);
- B3DHomMatrix& B3DHomMatrix::operator*=(const B3DHomMatrix& rMat)
- {
- if(!rMat.isIdentity())
- {
- implPrepareChange();
- mpM->doMulMatrix(*rMat.mpM);
+ mpM->doMulMatrix(aRotMatX);
}
- return *this;
- }
+ if(!::basegfx::fTools::equalZero(fAngleY))
+ {
+ Impl3DHomMatrix aRotMatY(get3DIdentityMatrix());
+ double fSin(sin(fAngleY));
+ double fCos(cos(fAngleY));
- sal_Bool B3DHomMatrix::operator==(const B3DHomMatrix& rMat) const
- {
- if(mpM == rMat.mpM)
- return sal_True;
+ aRotMatY.set(0, 0, fCos);
+ aRotMatY.set(2, 2, fCos);
+ aRotMatY.set(0, 2, fSin);
+ aRotMatY.set(2, 0, -fSin);
- return mpM->isEqual(*rMat.mpM);
- }
+ mpM->doMulMatrix(aRotMatY);
+ }
- sal_Bool B3DHomMatrix::operator!=(const B3DHomMatrix& rMat) const
- {
- if(mpM == rMat.mpM)
- return sal_False;
+ if(!::basegfx::fTools::equalZero(fAngleZ))
+ {
+ Impl3DHomMatrix aRotMatZ(get3DIdentityMatrix());
+ double fSin(sin(fAngleZ));
+ double fCos(cos(fAngleZ));
- return !mpM->isEqual(*rMat.mpM);
- }
+ aRotMatZ.set(0, 0, fCos);
+ aRotMatZ.set(1, 1, fCos);
+ aRotMatZ.set(1, 0, fSin);
+ aRotMatZ.set(0, 1, -fSin);
- void B3DHomMatrix::rotate(double fAngleX,double fAngleY,double fAngleZ)
- {
- if(!::basegfx::numeric::fTools::equalZero(fAngleX) || !::basegfx::numeric::fTools::equalZero(fAngleY) || !::basegfx::numeric::fTools::equalZero(fAngleZ))
- {
- implPrepareChange();
-
- if(!::basegfx::numeric::fTools::equalZero(fAngleX))
- {
- Impl3DHomMatrix aRotMatX(get3DIdentityMatrix());
- double fSin(sin(fAngleX));
- double fCos(cos(fAngleX));
-
- aRotMatX.set(1, 1, fCos);
- aRotMatX.set(2, 2, fCos);
- aRotMatX.set(2, 1, fSin);
- aRotMatX.set(1, 2, -fSin);
-
- mpM->doMulMatrix(aRotMatX);
- }
-
- if(!::basegfx::numeric::fTools::equalZero(fAngleY))
- {
- Impl3DHomMatrix aRotMatY(get3DIdentityMatrix());
- double fSin(sin(fAngleY));
- double fCos(cos(fAngleY));
-
- aRotMatY.set(0, 0, fCos);
- aRotMatY.set(2, 2, fCos);
- aRotMatY.set(0, 2, fSin);
- aRotMatY.set(2, 0, -fSin);
-
- mpM->doMulMatrix(aRotMatY);
- }
-
- if(!::basegfx::numeric::fTools::equalZero(fAngleZ))
- {
- Impl3DHomMatrix aRotMatZ(get3DIdentityMatrix());
- double fSin(sin(fAngleZ));
- double fCos(cos(fAngleZ));
-
- aRotMatZ.set(0, 0, fCos);
- aRotMatZ.set(1, 1, fCos);
- aRotMatZ.set(1, 0, fSin);
- aRotMatZ.set(0, 1, -fSin);
-
- mpM->doMulMatrix(aRotMatZ);
- }
+ mpM->doMulMatrix(aRotMatZ);
}
}
+ }
- void B3DHomMatrix::translate(double fX, double fY, double fZ)
+ void B3DHomMatrix::translate(double fX, double fY, double fZ)
+ {
+ if(!::basegfx::fTools::equalZero(fX) || !::basegfx::fTools::equalZero(fY) || !::basegfx::fTools::equalZero(fZ))
{
- if(!::basegfx::numeric::fTools::equalZero(fX) || !::basegfx::numeric::fTools::equalZero(fY) || !::basegfx::numeric::fTools::equalZero(fZ))
- {
- Impl3DHomMatrix aTransMat(get3DIdentityMatrix());
+ Impl3DHomMatrix aTransMat(get3DIdentityMatrix());
- aTransMat.set(0, 2, fX);
- aTransMat.set(1, 2, fY);
- aTransMat.set(2, 2, fZ);
+ aTransMat.set(0, 2, fX);
+ aTransMat.set(1, 2, fY);
+ aTransMat.set(2, 2, fZ);
- implPrepareChange();
- mpM->doMulMatrix(aTransMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aTransMat);
}
+ }
- void B3DHomMatrix::scale(double fX, double fY, double fZ)
- {
- const double fOne(1.0);
+ void B3DHomMatrix::scale(double fX, double fY, double fZ)
+ {
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equal(fOne, fX) || !::basegfx::numeric::fTools::equal(fOne, fY) ||!::basegfx::numeric::fTools::equal(fOne, fZ))
- {
- Impl3DHomMatrix aScaleMat(get3DIdentityMatrix());
+ if(!::basegfx::fTools::equal(fOne, fX) || !::basegfx::fTools::equal(fOne, fY) ||!::basegfx::fTools::equal(fOne, fZ))
+ {
+ Impl3DHomMatrix aScaleMat(get3DIdentityMatrix());
- aScaleMat.set(0, 0, fX);
- aScaleMat.set(1, 1, fY);
- aScaleMat.set(2, 2, fZ);
+ aScaleMat.set(0, 0, fX);
+ aScaleMat.set(1, 1, fY);
+ aScaleMat.set(2, 2, fZ);
- implPrepareChange();
- mpM->doMulMatrix(aScaleMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aScaleMat);
}
+ }
- void B3DHomMatrix::shearXY(double fSx, double fSy)
- {
- const double fOne(1.0);
+ void B3DHomMatrix::shearXY(double fSx, double fSy)
+ {
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equal(fOne, fSx) || !::basegfx::numeric::fTools::equal(fOne, fSy))
- {
- Impl3DHomMatrix aShearXYMat(get3DIdentityMatrix());
+ if(!::basegfx::fTools::equal(fOne, fSx) || !::basegfx::fTools::equal(fOne, fSy))
+ {
+ Impl3DHomMatrix aShearXYMat(get3DIdentityMatrix());
- aShearXYMat.set(0, 2, fSx);
- aShearXYMat.set(1, 2, fSy);
+ aShearXYMat.set(0, 2, fSx);
+ aShearXYMat.set(1, 2, fSy);
- implPrepareChange();
- mpM->doMulMatrix(aShearXYMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aShearXYMat);
}
+ }
- void B3DHomMatrix::shearYZ(double fSy, double fSz)
- {
- const double fOne(1.0);
+ void B3DHomMatrix::shearYZ(double fSy, double fSz)
+ {
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equal(fOne, fSy) || !::basegfx::numeric::fTools::equal(fOne, fSz))
- {
- Impl3DHomMatrix aShearYZMat(get3DIdentityMatrix());
+ if(!::basegfx::fTools::equal(fOne, fSy) || !::basegfx::fTools::equal(fOne, fSz))
+ {
+ Impl3DHomMatrix aShearYZMat(get3DIdentityMatrix());
- aShearYZMat.set(1, 0, fSy);
- aShearYZMat.set(2, 0, fSz);
+ aShearYZMat.set(1, 0, fSy);
+ aShearYZMat.set(2, 0, fSz);
- implPrepareChange();
- mpM->doMulMatrix(aShearYZMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aShearYZMat);
}
+ }
- void B3DHomMatrix::shearXZ(double fSx, double fSz)
- {
- const double fOne(1.0);
+ void B3DHomMatrix::shearXZ(double fSx, double fSz)
+ {
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equal(fOne, fSx) || !::basegfx::numeric::fTools::equal(fOne, fSz))
- {
- Impl3DHomMatrix aShearXZMat(get3DIdentityMatrix());
+ if(!::basegfx::fTools::equal(fOne, fSx) || !::basegfx::fTools::equal(fOne, fSz))
+ {
+ Impl3DHomMatrix aShearXZMat(get3DIdentityMatrix());
- aShearXZMat.set(0, 1, fSx);
- aShearXZMat.set(2, 1, fSz);
+ aShearXZMat.set(0, 1, fSx);
+ aShearXZMat.set(2, 1, fSz);
- implPrepareChange();
- mpM->doMulMatrix(aShearXZMat);
- }
+ implPrepareChange();
+ mpM->doMulMatrix(aShearXZMat);
}
+ }
- void B3DHomMatrix::frustum(double fLeft, double fRight, double fBottom, double fTop, double fNear, double fFar)
+ void B3DHomMatrix::frustum(double fLeft, double fRight, double fBottom, double fTop, double fNear, double fFar)
+ {
+ const double fZero(0.0);
+ const double fOne(1.0);
+
+ if(!::basegfx::fTools::more(fNear, fZero))
{
- const double fZero(0.0);
- const double fOne(1.0);
+ fNear = 0.001;
+ }
- if(!::basegfx::numeric::fTools::more(fNear, fZero))
- {
- fNear = 0.001;
- }
+ if(!::basegfx::fTools::more(fFar, fZero))
+ {
+ fFar = fOne;
+ }
- if(!::basegfx::numeric::fTools::more(fFar, fZero))
- {
- fFar = fOne;
- }
+ if(::basegfx::fTools::equal(fNear, fFar))
+ {
+ fFar = fNear + fOne;
+ }
- if(::basegfx::numeric::fTools::equal(fNear, fFar))
- {
- fFar = fNear + fOne;
- }
+ if(::basegfx::fTools::equal(fLeft, fRight))
+ {
+ fLeft -= fOne;
+ fRight += fOne;
+ }
- if(::basegfx::numeric::fTools::equal(fLeft, fRight))
- {
- fLeft -= fOne;
- fRight += fOne;
- }
+ if(::basegfx::fTools::equal(fTop, fBottom))
+ {
+ fBottom -= fOne;
+ fTop += fOne;
+ }
- if(::basegfx::numeric::fTools::equal(fTop, fBottom))
- {
- fBottom -= fOne;
- fTop += fOne;
- }
+ Impl3DHomMatrix aFrustumMat(get3DIdentityMatrix());
- Impl3DHomMatrix aFrustumMat(get3DIdentityMatrix());
+ aFrustumMat.set(0, 0, 2.0 * fNear / (fRight - fLeft));
+ aFrustumMat.set(1, 1, 2.0 * fNear / (fTop - fBottom));
+ aFrustumMat.set(0, 2, (fRight + fLeft) / (fRight - fLeft));
+ aFrustumMat.set(1, 2, (fTop + fBottom) / (fTop - fBottom));
+ aFrustumMat.set(2, 2, -fOne * ((fFar + fNear) / (fFar - fNear)));
+ aFrustumMat.set(3, 2, -fOne);
+ aFrustumMat.set(2, 3, -fOne * ((2.0 * fFar * fNear) / (fFar - fNear)));
+ aFrustumMat.set(3, 3, fZero);
- aFrustumMat.set(0, 0, 2.0 * fNear / (fRight - fLeft));
- aFrustumMat.set(1, 1, 2.0 * fNear / (fTop - fBottom));
- aFrustumMat.set(0, 2, (fRight + fLeft) / (fRight - fLeft));
- aFrustumMat.set(1, 2, (fTop + fBottom) / (fTop - fBottom));
- aFrustumMat.set(2, 2, -fOne * ((fFar + fNear) / (fFar - fNear)));
- aFrustumMat.set(3, 2, -fOne);
- aFrustumMat.set(2, 3, -fOne * ((2.0 * fFar * fNear) / (fFar - fNear)));
- aFrustumMat.set(3, 3, fZero);
+ if(mpM->getRefCount())
+ mpM->decRefCount();
+ else
+ delete mpM;
- if(mpM->getRefCount())
- mpM->decRefCount();
- else
- delete mpM;
+ mpM = new Impl3DHomMatrix(aFrustumMat);
+ }
- mpM = new Impl3DHomMatrix(aFrustumMat);
+ void B3DHomMatrix::ortho(double fLeft, double fRight, double fBottom, double fTop, double fNear, double fFar)
+ {
+ if(::basegfx::fTools::equal(fNear, fFar))
+ {
+ fFar = fNear + 1.0;
}
- void B3DHomMatrix::ortho(double fLeft, double fRight, double fBottom, double fTop, double fNear, double fFar)
+ if(::basegfx::fTools::equal(fLeft, fRight))
{
- if(::basegfx::numeric::fTools::equal(fNear, fFar))
- {
- fFar = fNear + 1.0;
- }
-
- if(::basegfx::numeric::fTools::equal(fLeft, fRight))
- {
- fLeft -= 1.0;
- fRight += 1.0;
- }
+ fLeft -= 1.0;
+ fRight += 1.0;
+ }
- if(::basegfx::numeric::fTools::equal(fTop, fBottom))
- {
- fBottom -= 1.0;
- fTop += 1.0;
- }
+ if(::basegfx::fTools::equal(fTop, fBottom))
+ {
+ fBottom -= 1.0;
+ fTop += 1.0;
+ }
- Impl3DHomMatrix aOrthoMat(get3DIdentityMatrix());
+ Impl3DHomMatrix aOrthoMat(get3DIdentityMatrix());
- aOrthoMat.set(0, 0, 2.0 / (fRight - fLeft));
- aOrthoMat.set(1, 1, 2.0 / (fTop - fBottom));
- aOrthoMat.set(2, 2, -1.0 * (2.0 / (fFar - fNear)));
- aOrthoMat.set(0, 3, -1.0 * ((fRight + fLeft) / (fRight - fLeft)));
- aOrthoMat.set(1, 3, -1.0 * ((fTop + fBottom) / (fTop - fBottom)));
- aOrthoMat.set(2, 3, -1.0 * ((fFar + fNear) / (fFar - fNear)));
+ aOrthoMat.set(0, 0, 2.0 / (fRight - fLeft));
+ aOrthoMat.set(1, 1, 2.0 / (fTop - fBottom));
+ aOrthoMat.set(2, 2, -1.0 * (2.0 / (fFar - fNear)));
+ aOrthoMat.set(0, 3, -1.0 * ((fRight + fLeft) / (fRight - fLeft)));
+ aOrthoMat.set(1, 3, -1.0 * ((fTop + fBottom) / (fTop - fBottom)));
+ aOrthoMat.set(2, 3, -1.0 * ((fFar + fNear) / (fFar - fNear)));
- if(mpM->getRefCount())
- mpM->decRefCount();
- else
- delete mpM;
+ if(mpM->getRefCount())
+ mpM->decRefCount();
+ else
+ delete mpM;
- mpM = new Impl3DHomMatrix(aOrthoMat);
- }
+ mpM = new Impl3DHomMatrix(aOrthoMat);
+ }
- sal_Bool B3DHomMatrix::decompose(tuple::B3DTuple& rScale, tuple::B3DTuple& rTranslate, tuple::B3DTuple& rRotate, tuple::B3DTuple& rShear) const
- {
- // when perspective is used, decompose is not made here
- if(!mpM->isLastLineDefault())
- return sal_False;
+ sal_Bool B3DHomMatrix::decompose(B3DTuple& rScale, B3DTuple& rTranslate, B3DTuple& rRotate, B3DTuple& rShear) const
+ {
+ // when perspective is used, decompose is not made here
+ if(!mpM->isLastLineDefault())
+ return sal_False;
- // If determinant is zero, decomposition is not possible
- if(0.0 == mpM->doDeterminant())
- return sal_False;
+ // If determinant is zero, decomposition is not possible
+ if(0.0 == mpM->doDeterminant())
+ return sal_False;
- // isolate translation
- rTranslate.setX(mpM->get(0, 3));
- rTranslate.setY(mpM->get(1, 3));
- rTranslate.setZ(mpM->get(2, 3));
+ // isolate translation
+ rTranslate.setX(mpM->get(0, 3));
+ rTranslate.setY(mpM->get(1, 3));
+ rTranslate.setZ(mpM->get(2, 3));
- // correct translate values
- rTranslate.correctValues();
+ // correct translate values
+ rTranslate.correctValues();
- // get scale and shear
- vector::B3DVector aCol0(mpM->get(0, 0), mpM->get(1, 0), mpM->get(2, 0));
- vector::B3DVector aCol1(mpM->get(0, 1), mpM->get(1, 1), mpM->get(2, 1));
- vector::B3DVector aCol2(mpM->get(0, 2), mpM->get(1, 2), mpM->get(2, 2));
- vector::B3DVector aTemp;
+ // get scale and shear
+ B3DVector aCol0(mpM->get(0, 0), mpM->get(1, 0), mpM->get(2, 0));
+ B3DVector aCol1(mpM->get(0, 1), mpM->get(1, 1), mpM->get(2, 1));
+ B3DVector aCol2(mpM->get(0, 2), mpM->get(1, 2), mpM->get(2, 2));
+ B3DVector aTemp;
- // get ScaleX
- rScale.setX(aCol0.getLength());
- aCol0.normalize();
+ // get ScaleX
+ rScale.setX(aCol0.getLength());
+ aCol0.normalize();
- // get ShearXY
- rShear.setX(aCol0.scalar(aCol1));
+ // get ShearXY
+ rShear.setX(aCol0.scalar(aCol1));
- if(::basegfx::numeric::fTools::equalZero(rShear.getX()))
- {
- rShear.setX(0.0);
- }
- else
- {
- aTemp.setX(aCol1.getX() - rShear.getX() * aCol0.getX());
- aTemp.setY(aCol1.getY() - rShear.getX() * aCol0.getY());
- aTemp.setZ(aCol1.getZ() - rShear.getX() * aCol0.getZ());
- aCol1 = aTemp;
- }
+ if(::basegfx::fTools::equalZero(rShear.getX()))
+ {
+ rShear.setX(0.0);
+ }
+ else
+ {
+ aTemp.setX(aCol1.getX() - rShear.getX() * aCol0.getX());
+ aTemp.setY(aCol1.getY() - rShear.getX() * aCol0.getY());
+ aTemp.setZ(aCol1.getZ() - rShear.getX() * aCol0.getZ());
+ aCol1 = aTemp;
+ }
- // get ScaleY
- rScale.setY(aCol1.getLength());
- aCol1.normalize();
+ // get ScaleY
+ rScale.setY(aCol1.getLength());
+ aCol1.normalize();
- const double fShearX(rShear.getX());
+ const double fShearX(rShear.getX());
- if(!::basegfx::numeric::fTools::equalZero(fShearX))
- {
- rShear.setX(rShear.getX() / rScale.getY());
- }
+ if(!::basegfx::fTools::equalZero(fShearX))
+ {
+ rShear.setX(rShear.getX() / rScale.getY());
+ }
- // get ShearXZ
- rShear.setY(aCol0.scalar(aCol2));
+ // get ShearXZ
+ rShear.setY(aCol0.scalar(aCol2));
- if(::basegfx::numeric::fTools::equalZero(rShear.getY()))
- {
- rShear.setY(0.0);
- }
- else
- {
- aTemp.setX(aCol2.getX() - rShear.getY() * aCol0.getX());
- aTemp.setY(aCol2.getY() - rShear.getY() * aCol0.getY());
- aTemp.setZ(aCol2.getZ() - rShear.getY() * aCol0.getZ());
- aCol2 = aTemp;
- }
+ if(::basegfx::fTools::equalZero(rShear.getY()))
+ {
+ rShear.setY(0.0);
+ }
+ else
+ {
+ aTemp.setX(aCol2.getX() - rShear.getY() * aCol0.getX());
+ aTemp.setY(aCol2.getY() - rShear.getY() * aCol0.getY());
+ aTemp.setZ(aCol2.getZ() - rShear.getY() * aCol0.getZ());
+ aCol2 = aTemp;
+ }
- // get ShearYZ
- rShear.setZ(aCol1.scalar(aCol2));
+ // get ShearYZ
+ rShear.setZ(aCol1.scalar(aCol2));
- if(::basegfx::numeric::fTools::equalZero(rShear.getZ()))
- {
- rShear.setZ(0.0);
- }
- else
- {
- aTemp.setX(aCol2.getX() - rShear.getZ() * aCol1.getX());
- aTemp.setY(aCol2.getY() - rShear.getZ() * aCol1.getY());
- aTemp.setZ(aCol2.getZ() - rShear.getZ() * aCol1.getZ());
- aCol2 = aTemp;
- }
+ if(::basegfx::fTools::equalZero(rShear.getZ()))
+ {
+ rShear.setZ(0.0);
+ }
+ else
+ {
+ aTemp.setX(aCol2.getX() - rShear.getZ() * aCol1.getX());
+ aTemp.setY(aCol2.getY() - rShear.getZ() * aCol1.getY());
+ aTemp.setZ(aCol2.getZ() - rShear.getZ() * aCol1.getZ());
+ aCol2 = aTemp;
+ }
- // get ScaleZ
- rScale.setZ(aCol2.getLength());
- aCol2.normalize();
+ // get ScaleZ
+ rScale.setZ(aCol2.getLength());
+ aCol2.normalize();
- const double fShearY(rShear.getY());
+ const double fShearY(rShear.getY());
- if(!::basegfx::numeric::fTools::equalZero(fShearY))
- {
- rShear.setY(rShear.getY() / rScale.getZ());
- }
+ if(!::basegfx::fTools::equalZero(fShearY))
+ {
+ rShear.setY(rShear.getY() / rScale.getZ());
+ }
- const double fShearZ(rShear.getZ());
+ const double fShearZ(rShear.getZ());
- if(!::basegfx::numeric::fTools::equalZero(fShearZ))
- {
- rShear.setZ(rShear.getZ() / rScale.getZ());
- }
+ if(!::basegfx::fTools::equalZero(fShearZ))
+ {
+ rShear.setZ(rShear.getZ() / rScale.getZ());
+ }
- // correct shear values
- rShear.correctValues();
+ // correct shear values
+ rShear.correctValues();
- // Coordinate system flip?
- if(0.0 > aCol0.scalar(aCol1.getPerpendicular(aCol2)))
- {
- rScale = -rScale;
- aCol0 = -aCol0;
- aCol1 = -aCol1;
- aCol2 = -aCol2;
- }
+ // Coordinate system flip?
+ if(0.0 > aCol0.scalar(aCol1.getPerpendicular(aCol2)))
+ {
+ rScale = -rScale;
+ aCol0 = -aCol0;
+ aCol1 = -aCol1;
+ aCol2 = -aCol2;
+ }
- // correct scale values
- rScale.correctValues(1.0);
+ // correct scale values
+ rScale.correctValues(1.0);
- // Get rotations
- rRotate.setY(asin(-aCol0.getZ()));
+ // Get rotations
+ rRotate.setY(asin(-aCol0.getZ()));
- if(::basegfx::numeric::fTools::equalZero(cos(rRotate.getY())))
- {
- rRotate.setX(atan2(aCol1.getX(), aCol1.getY()));
- rRotate.setZ(0.0);
- }
- else
- {
- rRotate.setX(atan2(aCol1.getZ(), aCol2.getZ()));
- rRotate.setZ(atan2(aCol0.getY(), aCol0.getX()));
- }
+ if(::basegfx::fTools::equalZero(cos(rRotate.getY())))
+ {
+ rRotate.setX(atan2(aCol1.getX(), aCol1.getY()));
+ rRotate.setZ(0.0);
+ }
+ else
+ {
+ rRotate.setX(atan2(aCol1.getZ(), aCol2.getZ()));
+ rRotate.setZ(atan2(aCol0.getY(), aCol0.getX()));
+ }
- // corrcet rotate values
- rRotate.correctValues();
+ // corrcet rotate values
+ rRotate.correctValues();
- return sal_True;
- }
- } // end of namespace matrix
+ return sal_True;
+ }
} // end of namespace basegfx
// eof