PoDoFo 1.0.0-dev
Loading...
Searching...
No Matches
Matrix.h
1
7#ifndef AUX_MATRIX_H
8#define AUX_MATRIX_H
9
10#include "MathBase.h"
11#include "Vector2.h"
12
13namespace PoDoFo
14{
15 class PdfArray;
16
17 class PODOFO_API Matrix final
18 {
19 public:
20 static Matrix Identity;
21
22 public:
25 Matrix();
26 Matrix(double a, double b, double c, double d, double e, double f);
27
28 public:
29 static Matrix FromArray(const double arr[6]);
30 static Matrix FromArray(const PdfArray& arr);
31 static Matrix CreateTranslation(const Vector2& tx);
32 static Matrix CreateScale(const Vector2& scale);
33 static Matrix CreateRotation(double teta);
34 static Matrix CreateRotation(const Vector2& center, double teta);
35
36 public:
37 // Prepend the given translation to the current matrix
38 Matrix& Translate(const Vector2& tx);
39
40 // Return the matrix with the given translation prepended
41 Matrix Translated(const Vector2& tx) const;
42
43 // TODO: Rotate/Scale
44
45 public:
46 template <AlgebraicTrait trait>
47 double Get() const
48 {
49 return MatrixTraits<trait>::Get(m_mat);
50 }
51
52 template <AlgebraicTrait trait>
53 void Set(double value)
54 {
55 MatrixTraits<trait>::Set(m_mat, value);
56 }
57
58 // Apply (prepend) the given operation
59 template <AlgebraicTrait trait>
60 Matrix& Apply(double value)
61 {
62 MatrixTraits<trait>::Apply(m_mat, value);
63 return *this;
64 }
65
66 public:
67 Matrix operator*(const Matrix& m) const;
68
69 public:
70 Matrix GetScalingRotation() const;
71 Matrix GetRotation() const;
72 Vector2 GetScaleVector() const;
73 Vector2 GetTranslationVector() const;
74 void ToArray(double arr[6]) const;
75 void ToArray(PdfArray& arr) const;
76 PdfArray ToArray() const;
77
78 public:
79 Matrix(const Matrix&) = default;
80 Matrix& operator=(const Matrix&) = default;
81 bool operator==(const Matrix& m) const;
82 bool operator!=(const Matrix& m) const;
83
84 public:
85 const double& operator[](unsigned idx) const;
86
87 private:
88 Matrix(const double arr[6]);
89
90 private:
91 double m_mat[6];
92 };
93}
94
95#endif // AUX_MATRIX_H
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition basetypes.h:16