PoDoFo 1.2.0
Loading...
Searching...
No Matches
MathBase.h
1// SPDX-FileCopyrightText: 2021 Francesco Pretto <ceztko@gmail.com>
2// SPDX-License-Identifier: LGPL-2.0-or-later OR MPL-2.0
3
4#ifndef AUX_MATH_BASE_H
5#define AUX_MATH_BASE_H
6
7namespace PoDoFo
8{
9 enum class AlgebraicTrait
10 {
11 Tx,
12 Ty,
13 // TODO: Scale/Rotation traits
14 };
15
18
19 template <AlgebraicTrait>
20 struct MatrixTraits;
21
22 template <>
23 struct MatrixTraits<Tx>
24 {
25 static double Get(const double m[6])
26 {
27 return m[4];
28 }
29
30 static void Set(double m[6], double value)
31 {
32 m[4] = value;
33 }
34
35 static void Apply(double m[6], double value)
36 {
37 m[4] = value * m[0] + m[4];
38 }
39 };
40
41 template <>
42 struct MatrixTraits<Ty>
43 {
44 static double Get(const double m[6])
45 {
46 return m[5];
47 }
48
49 static void Set(double m[6], double value)
50 {
51 m[5] = value;
52 }
53
54 static void Apply(double m[6], double value)
55 {
56 m[5] = value * m[3] + m[5];
57 }
58 };
59}
60
61#endif // AUX_MATH_BASE_H
All classes, functions, types and enums of PoDoFo are members of these namespace.
Definition basetypes.h:13
AlgebraicTrait
Definition MathBase.h:10
@ Tx
X Translation.
@ Ty
Y Translation.
constexpr AlgebraicTrait Ty
X Translation trait.
Definition MathBase.h:17
constexpr AlgebraicTrait Tx
X Translation trait.
Definition MathBase.h:16