Bump version to 6.4-15
[LibreOffice.git] / chart2 / source / view / main / Linear3DTransformation.cxx
blobc6802dc21b107d53563e00db374466004b405960
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <Linear3DTransformation.hxx>
21 #include <algorithm>
23 using namespace ::com::sun::star;
25 using ::com::sun::star::uno::Sequence;
27 namespace chart
30 Linear3DTransformation::Linear3DTransformation( const drawing::HomogenMatrix& rHomMatrix, bool bSwapXAndY )
31 : m_Matrix(rHomMatrix)
32 , m_bSwapXAndY(bSwapXAndY)
35 Linear3DTransformation::~Linear3DTransformation()
38 // ____ XTransformation ____
39 Sequence< double > SAL_CALL Linear3DTransformation::transform(
40 const Sequence< double >& rSourceValues )
42 double fX = rSourceValues[0];
43 double fY = rSourceValues[1];
44 double fZ = rSourceValues[2];
45 if(m_bSwapXAndY)
46 std::swap(fX,fY);
47 Sequence< double > aNewVec(3);
48 double fZwi;
50 fZwi = m_Matrix.Line1.Column1 * fX
51 + m_Matrix.Line1.Column2 * fY
52 + m_Matrix.Line1.Column3 * fZ
53 + m_Matrix.Line1.Column4;
54 aNewVec[0] = fZwi;
56 fZwi = m_Matrix.Line2.Column1 * fX
57 + m_Matrix.Line2.Column2 * fY
58 + m_Matrix.Line2.Column3 * fZ
59 + m_Matrix.Line2.Column4;
60 aNewVec[1] = fZwi;
62 fZwi = m_Matrix.Line3.Column1 * fX
63 + m_Matrix.Line3.Column2 * fY
64 + m_Matrix.Line3.Column3 * fZ
65 + m_Matrix.Line3.Column4;
66 aNewVec[2] = fZwi;
68 fZwi = m_Matrix.Line4.Column1 * fX
69 + m_Matrix.Line4.Column2 * fY
70 + m_Matrix.Line4.Column3 * fZ
71 + m_Matrix.Line4.Column4;
72 if(fZwi != 1.0 && fZwi != 0.0)
74 aNewVec[0] /= fZwi;
75 aNewVec[1] /= fZwi;
76 aNewVec[2] /= fZwi;
78 return aNewVec;
81 sal_Int32 SAL_CALL Linear3DTransformation::getSourceDimension()
83 return 3;
86 sal_Int32 SAL_CALL Linear3DTransformation::getTargetDimension()
88 return 3;
91 } // namespace chart
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */