summaryrefslogtreecommitdiffstats
path: root/include/basegfx/tuple/Tuple3D.hxx
blob: 0b528c8341749fb0c1e0ec97d8e95f3d2092c9b3 (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 */

#pragma once

namespace basegfx
{
template <typename TYPE> class Tuple3D
{
protected:
    TYPE mnX;
    TYPE mnY;
    TYPE mnZ;

public:
    /** Create a 3D Tuple

            @param x
            This parameter is used to initialize the X-coordinate
            of the 3D Tuple.

            @param y
            This parameter is used to initialize the Y-coordinate
            of the 3D Tuple.

            @param z
            This parameter is used to initialize the Z-coordinate
            of the 3D Tuple.
        */
    Tuple3D(TYPE x, TYPE y, TYPE z)
        : mnX(x)
        , mnY(y)
        , mnZ(z)
    {
    }

    /// Get X-Coordinate of 3D Tuple
    TYPE getX() const { return mnX; }

    /// Get Y-Coordinate of 3D Tuple
    TYPE getY() const { return mnY; }

    /// Get Z-Coordinate of 3D Tuple
    TYPE getZ() const { return mnZ; }

    /// Set X-Coordinate of 3D Tuple
    void setX(TYPE fX) { mnX = fX; }

    /// Set Y-Coordinate of 3D Tuple
    void setY(TYPE fY) { mnY = fY; }

    /// Set Z-Coordinate of 3D Tuple
    void setZ(TYPE fZ) { mnZ = fZ; }

    // operators

    Tuple3D& operator+=(const Tuple3D& rTup)
    {
        mnX += rTup.mnX;
        mnY += rTup.mnY;
        mnZ += rTup.mnZ;
        return *this;
    }

    Tuple3D& operator-=(const Tuple3D& rTup)
    {
        mnX -= rTup.mnX;
        mnY -= rTup.mnY;
        mnZ -= rTup.mnZ;
        return *this;
    }

    Tuple3D& operator/=(const Tuple3D& rTup)
    {
        mnX /= rTup.mnX;
        mnY /= rTup.mnY;
        mnZ /= rTup.mnZ;
        return *this;
    }

    Tuple3D& operator*=(const Tuple3D& rTup)
    {
        mnX *= rTup.mnX;
        mnY *= rTup.mnY;
        mnZ *= rTup.mnZ;
        return *this;
    }

    Tuple3D& operator*=(TYPE t)
    {
        mnX *= t;
        mnY *= t;
        mnZ *= t;
        return *this;
    }

    Tuple3D& operator/=(TYPE t)
    {
        mnX /= t;
        mnY /= t;
        mnZ /= t;
        return *this;
    }

    bool operator==(const Tuple3D& rTup) const
    {
        return mnX == rTup.mnX && mnY == rTup.mnY && mnZ == rTup.mnZ;
    }

    bool operator!=(const Tuple3D& rTup) const { return !operator==(rTup); }
};

} // end of namespace basegfx

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */