LibreOffice Module basegfx (master) 1
Tuple3D.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 */
10
11#pragma once
12
13namespace basegfx
14{
15template <typename TYPE> class Tuple3D
16{
17protected:
18 union {
19 // temporary alias mnX with mfX, mnY with mfY and mnZ with mfZ
20 struct
21 {
25 };
26 struct
27 {
31 };
32 };
33
34public:
49 Tuple3D(TYPE x, TYPE y, TYPE z)
50 : mnX(x)
51 , mnY(y)
52 , mnZ(z)
53 {
54 }
55
57 TYPE getX() const { return mnX; }
58
60 TYPE getY() const { return mnY; }
61
63 TYPE getZ() const { return mnZ; }
64
66 void setX(TYPE fX) { mnX = fX; }
67
69 void setY(TYPE fY) { mnY = fY; }
70
72 void setZ(TYPE fZ) { mnZ = fZ; }
73
74 // operators
75
77 {
78 mfX += rTup.mfX;
79 mfY += rTup.mfY;
80 mfZ += rTup.mfZ;
81 return *this;
82 }
83
85 {
86 mfX -= rTup.mfX;
87 mfY -= rTup.mfY;
88 mfZ -= rTup.mfZ;
89 return *this;
90 }
91
93 {
94 mfX /= rTup.mfX;
95 mfY /= rTup.mfY;
96 mfZ /= rTup.mfZ;
97 return *this;
98 }
99
101 {
102 mfX *= rTup.mfX;
103 mfY *= rTup.mfY;
104 mfZ *= rTup.mfZ;
105 return *this;
106 }
107
109 {
110 mfX *= t;
111 mfY *= t;
112 mfZ *= t;
113 return *this;
114 }
115
117 {
118 mfX /= t;
119 mfY /= t;
120 mfZ /= t;
121 return *this;
122 }
123
124 bool operator==(const Tuple3D& rTup) const
125 {
126 return mfX == rTup.mfX && mfY == rTup.mfY && mfZ == rTup.mfZ;
127 }
128
129 bool operator!=(const Tuple3D& rTup) const { return !operator==(rTup); }
130};
131
132} // end of namespace basegfx
133
134/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XPropertyListType t
Tuple3D(TYPE x, TYPE y, TYPE z)
Create a 3D Tuple.
Definition: Tuple3D.hxx:49
Tuple3D & operator*=(const Tuple3D &rTup)
Definition: Tuple3D.hxx:100
void setX(TYPE fX)
Set X-Coordinate of 3D Tuple.
Definition: Tuple3D.hxx:66
TYPE getX() const
Get X-Coordinate of 3D Tuple.
Definition: Tuple3D.hxx:57
TYPE getZ() const
Get Z-Coordinate of 3D Tuple.
Definition: Tuple3D.hxx:63
Tuple3D & operator-=(const Tuple3D &rTup)
Definition: Tuple3D.hxx:84
Tuple3D & operator/=(const Tuple3D &rTup)
Definition: Tuple3D.hxx:92
Tuple3D & operator*=(TYPE t)
Definition: Tuple3D.hxx:108
TYPE getY() const
Get Y-Coordinate of 3D Tuple.
Definition: Tuple3D.hxx:60
bool operator==(const Tuple3D &rTup) const
Definition: Tuple3D.hxx:124
Tuple3D & operator/=(TYPE t)
Definition: Tuple3D.hxx:116
void setY(TYPE fY)
Set Y-Coordinate of 3D Tuple.
Definition: Tuple3D.hxx:69
Tuple3D & operator+=(const Tuple3D &rTup)
Definition: Tuple3D.hxx:76
void setZ(TYPE fZ)
Set Z-Coordinate of 3D Tuple.
Definition: Tuple3D.hxx:72
bool operator!=(const Tuple3D &rTup) const
Definition: Tuple3D.hxx:129
float y
float x
float z
TYPE