xref: /trunk/main/basegfx/source/point/b3ipoint.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_basegfx.hxx"
30 #include <basegfx/point/b3ipoint.hxx>
31 #include <basegfx/matrix/b3dhommatrix.hxx>
32 #include <basegfx/numeric/ftools.hxx>
33 
34 namespace basegfx
35 {
36     B3IPoint& B3IPoint::operator*=( const ::basegfx::B3DHomMatrix& rMat )
37     {
38         double fTempX(
39             rMat.get(0, 0) * mnX +
40             rMat.get(0, 1) * mnY +
41             rMat.get(0, 2) * mnZ +
42             rMat.get(0, 3));
43         double fTempY(
44             rMat.get(1, 0) * mnX +
45             rMat.get(1, 1) * mnY +
46             rMat.get(1, 2) * mnZ +
47             rMat.get(1, 3));
48         double fTempZ(
49             rMat.get(2, 0) * mnX +
50             rMat.get(2, 1) * mnY +
51             rMat.get(2, 2) * mnZ +
52             rMat.get(2, 3));
53 
54         if(!rMat.isLastLineDefault())
55         {
56             const double fOne(1.0);
57             const double fTempM(
58                 rMat.get(3, 0) * mnX +
59                 rMat.get(3, 1) * mnY +
60                 rMat.get(3, 2) * mnZ +
61                 rMat.get(3, 3));
62 
63             if(!fTools::equalZero(fTempM) && !fTools::equal(fOne, fTempM))
64             {
65                 fTempX /= fTempM;
66                 fTempY /= fTempM;
67                 fTempZ /= fTempM;
68             }
69         }
70 
71         mnX = fround(fTempX);
72         mnY = fround(fTempY);
73         mnZ = fround(fTempZ);
74 
75         return *this;
76     }
77 } // end of namespace basegfx
78 
79 // eof
80