aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Audio/Renderer/Utils/Math/Matrix2x2.cs
blob: 5b513aff3267656cfd0622f1af5b7e97a3fc9f80 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
namespace Ryujinx.Audio.Renderer.Utils.Math
{
    record struct Matrix2x2
    {
        public float M11;
        public float M12;
        public float M21;
        public float M22;

        public Matrix2x2(float m11, float m12,
                         float m21, float m22)
        {
            M11 = m11;
            M12 = m12;

            M21 = m21;
            M22 = m22;
        }

        public static Matrix2x2 operator +(Matrix2x2 value1, Matrix2x2 value2)
        {
            Matrix2x2 m;

            m.M11 = value1.M11 + value2.M11;
            m.M12 = value1.M12 + value2.M12;
            m.M21 = value1.M21 + value2.M21;
            m.M22 = value1.M22 + value2.M22;

            return m;
        }

        public static Matrix2x2 operator -(Matrix2x2 value1, float value2)
        {
            Matrix2x2 m;

            m.M11 = value1.M11 - value2;
            m.M12 = value1.M12 - value2;
            m.M21 = value1.M21 - value2;
            m.M22 = value1.M22 - value2;

            return m;
        }

        public static Matrix2x2 operator *(Matrix2x2 value1, float value2)
        {
            Matrix2x2 m;

            m.M11 = value1.M11 * value2;
            m.M12 = value1.M12 * value2;
            m.M21 = value1.M21 * value2;
            m.M22 = value1.M22 * value2;

            return m;
        }

        public static Matrix2x2 operator *(Matrix2x2 value1, Matrix2x2 value2)
        {
            Matrix2x2 m;

            // First row
            m.M11 = value1.M11 * value2.M11 + value1.M12 * value2.M21;
            m.M12 = value1.M11 * value2.M12 + value1.M12 * value2.M22;

            // Second row
            m.M21 = value1.M21 * value2.M11 + value1.M22 * value2.M21;
            m.M22 = value1.M21 * value2.M12 + value1.M22 * value2.M22;

            return m;
        }
    }
}