Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/view/main/Linear3DTransformation.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
20
#include <Linear3DTransformation.hxx>
21
22
using namespace ::com::sun::star;
23
24
using ::com::sun::star::uno::Sequence;
25
26
namespace chart
27
{
28
29
    Linear3DTransformation::Linear3DTransformation( const drawing::HomogenMatrix& rHomMatrix, bool bSwapXAndY )
30
0
    : m_Matrix(rHomMatrix)
31
0
    , m_bSwapXAndY(bSwapXAndY)
32
0
{}
33
34
Linear3DTransformation::~Linear3DTransformation()
35
0
{}
36
37
// ____ XTransformation2 ____
38
css::drawing::Position3D Linear3DTransformation::transform(
39
                        const Sequence< double >& rSourceValues ) const
40
0
{
41
0
    double fX = rSourceValues[0];
42
0
    double fY = rSourceValues[1];
43
0
    double fZ = rSourceValues[2];
44
0
    if(m_bSwapXAndY)
45
0
        std::swap(fX,fY);
46
0
    css::drawing::Position3D aNewVec;
47
0
    double fZwi;
48
49
0
    fZwi = m_Matrix.Line1.Column1 * fX
50
0
         + m_Matrix.Line1.Column2 * fY
51
0
         + m_Matrix.Line1.Column3 * fZ
52
0
         + m_Matrix.Line1.Column4;
53
0
    aNewVec.PositionX = fZwi;
54
55
0
    fZwi = m_Matrix.Line2.Column1 * fX
56
0
         + m_Matrix.Line2.Column2 * fY
57
0
         + m_Matrix.Line2.Column3 * fZ
58
0
         + m_Matrix.Line2.Column4;
59
0
    aNewVec.PositionY = fZwi;
60
61
0
    fZwi = m_Matrix.Line3.Column1 * fX
62
0
         + m_Matrix.Line3.Column2 * fY
63
0
         + m_Matrix.Line3.Column3 * fZ
64
0
         + m_Matrix.Line3.Column4;
65
0
    aNewVec.PositionZ = fZwi;
66
67
0
    fZwi = m_Matrix.Line4.Column1 * fX
68
0
         + m_Matrix.Line4.Column2 * fY
69
0
         + m_Matrix.Line4.Column3 * fZ
70
0
         + m_Matrix.Line4.Column4;
71
0
    if(fZwi != 1.0 && fZwi != 0.0)
72
0
    {
73
0
        aNewVec.PositionX /= fZwi;
74
0
        aNewVec.PositionY /= fZwi;
75
0
        aNewVec.PositionZ /= fZwi;
76
0
    }
77
0
    return aNewVec;
78
0
}
79
80
css::drawing::Position3D Linear3DTransformation::transform(
81
                        const css::drawing::Position3D& rSourceValues ) const
82
0
{
83
0
    double fX = rSourceValues.PositionX;
84
0
    double fY = rSourceValues.PositionY;
85
0
    double fZ = rSourceValues.PositionZ;
86
0
    if(m_bSwapXAndY)
87
0
        std::swap(fX,fY);
88
0
    css::drawing::Position3D aNewVec;
89
0
    double fZwi;
90
91
0
    fZwi = m_Matrix.Line1.Column1 * fX
92
0
         + m_Matrix.Line1.Column2 * fY
93
0
         + m_Matrix.Line1.Column3 * fZ
94
0
         + m_Matrix.Line1.Column4;
95
0
    aNewVec.PositionX = fZwi;
96
97
0
    fZwi = m_Matrix.Line2.Column1 * fX
98
0
         + m_Matrix.Line2.Column2 * fY
99
0
         + m_Matrix.Line2.Column3 * fZ
100
0
         + m_Matrix.Line2.Column4;
101
0
    aNewVec.PositionY = fZwi;
102
103
0
    fZwi = m_Matrix.Line3.Column1 * fX
104
0
         + m_Matrix.Line3.Column2 * fY
105
0
         + m_Matrix.Line3.Column3 * fZ
106
0
         + m_Matrix.Line3.Column4;
107
0
    aNewVec.PositionZ = fZwi;
108
109
0
    fZwi = m_Matrix.Line4.Column1 * fX
110
0
         + m_Matrix.Line4.Column2 * fY
111
0
         + m_Matrix.Line4.Column3 * fZ
112
0
         + m_Matrix.Line4.Column4;
113
0
    if(fZwi != 1.0 && fZwi != 0.0)
114
0
    {
115
0
        aNewVec.PositionX /= fZwi;
116
0
        aNewVec.PositionY /= fZwi;
117
0
        aNewVec.PositionZ /= fZwi;
118
0
    }
119
0
    return aNewVec;
120
0
}
121
122
}  // namespace chart
123
124
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */