Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / basegfx / tuple / Tuple3D.hxx
blob96751666393dfda1c5446b74a952f3f5b8971f0f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 */
11 #pragma once
13 namespace basegfx
15 template <typename TYPE> class Tuple3D
17 protected:
18 union {
19 // temporary alias mnX with mfX, mnY with mfY and mnZ with mfZ
20 struct
22 TYPE mnX;
23 TYPE mnY;
24 TYPE mnZ;
26 struct
28 TYPE mfX;
29 TYPE mfY;
30 TYPE mfZ;
34 public:
35 /** Create a 3D Tuple
37 @param x
38 This parameter is used to initialize the X-coordinate
39 of the 3D Tuple.
41 @param y
42 This parameter is used to initialize the Y-coordinate
43 of the 3D Tuple.
45 @param z
46 This parameter is used to initialize the Z-coordinate
47 of the 3D Tuple.
49 Tuple3D(TYPE x, TYPE y, TYPE z)
50 : mnX(x)
51 , mnY(y)
52 , mnZ(z)
56 /// Get X-Coordinate of 3D Tuple
57 TYPE getX() const { return mnX; }
59 /// Get Y-Coordinate of 3D Tuple
60 TYPE getY() const { return mnY; }
62 /// Get Z-Coordinate of 3D Tuple
63 TYPE getZ() const { return mnZ; }
65 /// Set X-Coordinate of 3D Tuple
66 void setX(TYPE fX) { mnX = fX; }
68 /// Set Y-Coordinate of 3D Tuple
69 void setY(TYPE fY) { mnY = fY; }
71 /// Set Z-Coordinate of 3D Tuple
72 void setZ(TYPE fZ) { mnZ = fZ; }
74 // operators
76 Tuple3D& operator+=(const Tuple3D& rTup)
78 mfX += rTup.mfX;
79 mfY += rTup.mfY;
80 mfZ += rTup.mfZ;
81 return *this;
84 Tuple3D& operator-=(const Tuple3D& rTup)
86 mfX -= rTup.mfX;
87 mfY -= rTup.mfY;
88 mfZ -= rTup.mfZ;
89 return *this;
92 Tuple3D& operator/=(const Tuple3D& rTup)
94 mfX /= rTup.mfX;
95 mfY /= rTup.mfY;
96 mfZ /= rTup.mfZ;
97 return *this;
100 Tuple3D& operator*=(const Tuple3D& rTup)
102 mfX *= rTup.mfX;
103 mfY *= rTup.mfY;
104 mfZ *= rTup.mfZ;
105 return *this;
108 Tuple3D& operator*=(TYPE t)
110 mfX *= t;
111 mfY *= t;
112 mfZ *= t;
113 return *this;
116 Tuple3D& operator/=(TYPE t)
118 mfX /= t;
119 mfY /= t;
120 mfZ /= t;
121 return *this;
124 bool operator==(const Tuple3D& rTup) const
126 return mfX == rTup.mfX && mfY == rTup.mfY && mfZ == rTup.mfZ;
129 bool operator!=(const Tuple3D& rTup) const { return !operator==(rTup); }
132 } // end of namespace basegfx
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */