/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// linear combine another matrix with decomposition results
B2DHomMatrix aRecombined;
impFillMatrix(aRecombined, aDScale.getX(), aDScale.getY(), fDShX, fDRot);
// if decomposition worked, matrices need to be the same return bWorked && aSource == aRecombined;
}
void decompose()
{ // test matrix decompositions. Each matrix decomposed and rebuilt // using the decompose result should be the same as before. Test // with all ranges of values. Translations are not tested since these // are just the two rightmost values and uncritical staticconstdouble fSX(10.0); staticconstdouble fSY(12.0); staticconstdouble fR(M_PI_4); staticconstdouble fS(deg2rad(15.0));
// check all possible scaling combinations
CPPUNIT_ASSERT_MESSAGE("decompose: error test A1",
impDecomposeComposeTest(fSX, fSY, 0.0, 0.0));
CPPUNIT_ASSERT_MESSAGE("decompose: error test A2",
impDecomposeComposeTest(-fSX, fSY, 0.0, 0.0));
CPPUNIT_ASSERT_MESSAGE("decompose: error test A3",
impDecomposeComposeTest(fSX, -fSY, 0.0, 0.0));
CPPUNIT_ASSERT_MESSAGE("decompose: error test A4",
impDecomposeComposeTest(-fSX, -fSY, 0.0, 0.0));
// check all possible scaling combinations with positive rotation
CPPUNIT_ASSERT_MESSAGE("decompose: error test B1",
impDecomposeComposeTest(fSX, fSY, 0.0, fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test B2",
impDecomposeComposeTest(-fSX, fSY, 0.0, fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test B3",
impDecomposeComposeTest(fSX, -fSY, 0.0, fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test B4",
impDecomposeComposeTest(-fSX, -fSY, 0.0, fR));
// check all possible scaling combinations with negative rotation
CPPUNIT_ASSERT_MESSAGE("decompose: error test C1",
impDecomposeComposeTest(fSX, fSY, 0.0, -fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test C2",
impDecomposeComposeTest(-fSX, fSY, 0.0, -fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test C3",
impDecomposeComposeTest(fSX, -fSY, 0.0, -fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test C4",
impDecomposeComposeTest(-fSX, -fSY, 0.0, -fR));
// check all possible scaling combinations with positive shear
CPPUNIT_ASSERT_MESSAGE("decompose: error test D1",
impDecomposeComposeTest(fSX, fSY, tan(fS), 0.0));
CPPUNIT_ASSERT_MESSAGE("decompose: error test D2",
impDecomposeComposeTest(-fSX, fSY, tan(fS), 0.0));
CPPUNIT_ASSERT_MESSAGE("decompose: error test D3",
impDecomposeComposeTest(fSX, -fSY, tan(fS), 0.0));
CPPUNIT_ASSERT_MESSAGE("decompose: error test D4",
impDecomposeComposeTest(-fSX, -fSY, tan(fS), 0.0));
// check all possible scaling combinations with negative shear
CPPUNIT_ASSERT_MESSAGE("decompose: error test E1",
impDecomposeComposeTest(fSX, fSY, tan(-fS), 0.0));
CPPUNIT_ASSERT_MESSAGE("decompose: error test E2",
impDecomposeComposeTest(-fSX, fSY, tan(-fS), 0.0));
CPPUNIT_ASSERT_MESSAGE("decompose: error test E3",
impDecomposeComposeTest(fSX, -fSY, tan(-fS), 0.0));
CPPUNIT_ASSERT_MESSAGE("decompose: error test E4",
impDecomposeComposeTest(-fSX, -fSY, tan(-fS), 0.0));
// check all possible scaling combinations with positive rotate and positive shear
CPPUNIT_ASSERT_MESSAGE("decompose: error test F1",
impDecomposeComposeTest(fSX, fSY, tan(fS), fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test F2",
impDecomposeComposeTest(-fSX, fSY, tan(fS), fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test F3",
impDecomposeComposeTest(fSX, -fSY, tan(fS), fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test F4",
impDecomposeComposeTest(-fSX, -fSY, tan(fS), fR));
// check all possible scaling combinations with negative rotate and positive shear
CPPUNIT_ASSERT_MESSAGE("decompose: error test G1",
impDecomposeComposeTest(fSX, fSY, tan(fS), -fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test G2",
impDecomposeComposeTest(-fSX, fSY, tan(fS), -fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test G3",
impDecomposeComposeTest(fSX, -fSY, tan(fS), -fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test G4",
impDecomposeComposeTest(-fSX, -fSY, tan(fS), -fR));
// check all possible scaling combinations with positive rotate and negative shear
CPPUNIT_ASSERT_MESSAGE("decompose: error test H1",
impDecomposeComposeTest(fSX, fSY, tan(-fS), fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test H2",
impDecomposeComposeTest(-fSX, fSY, tan(-fS), fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test H3",
impDecomposeComposeTest(fSX, -fSY, tan(-fS), fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test H4",
impDecomposeComposeTest(-fSX, -fSY, tan(-fS), fR));
// check all possible scaling combinations with negative rotate and negative shear
CPPUNIT_ASSERT_MESSAGE("decompose: error test I1",
impDecomposeComposeTest(fSX, fSY, tan(-fS), -fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test I2",
impDecomposeComposeTest(-fSX, fSY, tan(-fS), -fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test I3",
impDecomposeComposeTest(fSX, -fSY, tan(-fS), -fR));
CPPUNIT_ASSERT_MESSAGE("decompose: error test I4",
impDecomposeComposeTest(-fSX, -fSY, tan(-fS), -fR));
// cover special case of 180 degree rotation
B2DHomMatrix aTest
= utils::createScaleShearXRotateTranslateB2DHomMatrix(6425, 3938, 0, M_PI, 10482, 4921); // decompose that matrix
B2DTuple aDScale;
B2DTuple aDTrans; double fDRot; double fDShX;
aTest.decompose(aDScale, aDTrans, fDRot, fDShX);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("decompose: error test J1", 6425.0, aDScale.getX(),
1E-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("decompose: error test J1", 3938.0, aDScale.getY(),
1E-12);
CPPUNIT_ASSERT_EQUAL_MESSAGE("decompose: error test J1", 10482.0, aDTrans.getX());
CPPUNIT_ASSERT_EQUAL_MESSAGE("decompose: error test J1", 4921.0, aDTrans.getY());
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("decompose: error test J1", M_PI, fDRot, 1E-12);
}
// Change the following lines only, if you add, remove or rename // member functions of the current class, // because these macros are need by auto register mechanism.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.