Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/vcl/inc/pdf/Matrix3.hxx
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
 */
10
11
#pragma once
12
13
#include <basegfx/point/b2dpoint.hxx>
14
#include <tools/gen.hxx>
15
16
namespace vcl::pdf
17
{
18
// matrix helper class
19
// TODO: use basegfx matrix class instead or derive from it
20
21
/*  for sparse matrices of the form (2D linear transformations)
22
 *  f[0] f[1] 0
23
 *  f[2] f[3] 0
24
 *  f[4] f[5] 1
25
 */
26
class Matrix3
27
{
28
    double f[6];
29
30
    void set(const double* pn)
31
507k
    {
32
3.55M
        for (int i = 0; i < 6; i++)
33
3.04M
            f[i] = pn[i];
34
507k
    }
35
36
public:
37
    Matrix3();
38
39
    void skew(double alpha, double beta);
40
    void scale(double sx, double sy);
41
    void rotate(double angle);
42
    void translate(double tx, double ty);
43
    void invert();
44
45
315k
    double get(size_t i) const { return f[i]; }
46
47
    Point transform(const Point& rPoint) const;
48
    basegfx::B2DPoint transform(const basegfx::B2DPoint& rPoint) const;
49
};
50
}
51
52
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */