]> git.sesse.net Git - casparcg/blob - dependencies64/sfml/include/SFML/System/Vector3.hpp
28d0c07603126233f95ae5127e0a52fef09bc539
[casparcg] / dependencies64 / sfml / include / SFML / System / Vector3.hpp
1 ////////////////////////////////////////////////////////////
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2014 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 //    you must not claim that you wrote the original software.
15 //    If you use this software in a product, an acknowledgment
16 //    in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 //    and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
23 ////////////////////////////////////////////////////////////
24
25 #ifndef SFML_VECTOR3_HPP
26 #define SFML_VECTOR3_HPP
27
28
29 namespace sf
30 {
31 ////////////////////////////////////////////////////////////
32 /// \brief Utility template class for manipulating
33 ///        3-dimensional vectors
34 ///
35 ////////////////////////////////////////////////////////////
36 template <typename T>
37 class Vector3
38 {
39 public:
40
41     ////////////////////////////////////////////////////////////
42     /// \brief Default constructor
43     ///
44     /// Creates a Vector3(0, 0, 0).
45     ///
46     ////////////////////////////////////////////////////////////
47     Vector3();
48
49     ////////////////////////////////////////////////////////////
50     /// \brief Construct the vector from its coordinates
51     ///
52     /// \param X X coordinate
53     /// \param Y Y coordinate
54     /// \param Z Z coordinate
55     ///
56     ////////////////////////////////////////////////////////////
57     Vector3(T X, T Y, T Z);
58
59     ////////////////////////////////////////////////////////////
60     /// \brief Construct the vector from another type of vector
61     ///
62     /// This constructor doesn't replace the copy constructor,
63     /// it's called only when U != T.
64     /// A call to this constructor will fail to compile if U
65     /// is not convertible to T.
66     ///
67     /// \param vector Vector to convert
68     ///
69     ////////////////////////////////////////////////////////////
70     template <typename U>
71     explicit Vector3(const Vector3<U>& vector);
72
73     ////////////////////////////////////////////////////////////
74     // Member data
75     ////////////////////////////////////////////////////////////
76     T x; ///< X coordinate of the vector
77     T y; ///< Y coordinate of the vector
78     T z; ///< Z coordinate of the vector
79 };
80
81 ////////////////////////////////////////////////////////////
82 /// \relates Vector3
83 /// \brief Overload of unary operator -
84 ///
85 /// \param left Vector to negate
86 ///
87 /// \return Memberwise opposite of the vector
88 ///
89 ////////////////////////////////////////////////////////////
90 template <typename T>
91 Vector3<T> operator -(const Vector3<T>& left);
92
93 ////////////////////////////////////////////////////////////
94 /// \relates Vector3
95 /// \brief Overload of binary operator +=
96 ///
97 /// This operator performs a memberwise addition of both vectors,
98 /// and assigns the result to \a left.
99 ///
100 /// \param left  Left operand (a vector)
101 /// \param right Right operand (a vector)
102 ///
103 /// \return Reference to \a left
104 ///
105 ////////////////////////////////////////////////////////////
106 template <typename T>
107 Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right);
108
109 ////////////////////////////////////////////////////////////
110 /// \relates Vector3
111 /// \brief Overload of binary operator -=
112 ///
113 /// This operator performs a memberwise subtraction of both vectors,
114 /// and assigns the result to \a left.
115 ///
116 /// \param left  Left operand (a vector)
117 /// \param right Right operand (a vector)
118 ///
119 /// \return Reference to \a left
120 ///
121 ////////////////////////////////////////////////////////////
122 template <typename T>
123 Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right);
124
125 ////////////////////////////////////////////////////////////
126 /// \relates Vector3
127 /// \brief Overload of binary operator +
128 ///
129 /// \param left  Left operand (a vector)
130 /// \param right Right operand (a vector)
131 ///
132 /// \return Memberwise addition of both vectors
133 ///
134 ////////////////////////////////////////////////////////////
135 template <typename T>
136 Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right);
137
138 ////////////////////////////////////////////////////////////
139 /// \relates Vector3
140 /// \brief Overload of binary operator -
141 ///
142 /// \param left  Left operand (a vector)
143 /// \param right Right operand (a vector)
144 ///
145 /// \return Memberwise subtraction of both vectors
146 ///
147 ////////////////////////////////////////////////////////////
148 template <typename T>
149 Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right);
150
151 ////////////////////////////////////////////////////////////
152 /// \relates Vector3
153 /// \brief Overload of binary operator *
154 ///
155 /// \param left  Left operand (a vector)
156 /// \param right Right operand (a scalar value)
157 ///
158 /// \return Memberwise multiplication by \a right
159 ///
160 ////////////////////////////////////////////////////////////
161 template <typename T>
162 Vector3<T> operator *(const Vector3<T>& left, T right);
163
164 ////////////////////////////////////////////////////////////
165 /// \relates Vector3
166 /// \brief Overload of binary operator *
167 ///
168 /// \param left  Left operand (a scalar value)
169 /// \param right Right operand (a vector)
170 ///
171 /// \return Memberwise multiplication by \a left
172 ///
173 ////////////////////////////////////////////////////////////
174 template <typename T>
175 Vector3<T> operator *(T left, const Vector3<T>& right);
176
177 ////////////////////////////////////////////////////////////
178 /// \relates Vector3
179 /// \brief Overload of binary operator *=
180 ///
181 /// This operator performs a memberwise multiplication by \a right,
182 /// and assigns the result to \a left.
183 ///
184 /// \param left  Left operand (a vector)
185 /// \param right Right operand (a scalar value)
186 ///
187 /// \return Reference to \a left
188 ///
189 ////////////////////////////////////////////////////////////
190 template <typename T>
191 Vector3<T>& operator *=(Vector3<T>& left, T right);
192
193 ////////////////////////////////////////////////////////////
194 /// \relates Vector3
195 /// \brief Overload of binary operator /
196 ///
197 /// \param left  Left operand (a vector)
198 /// \param right Right operand (a scalar value)
199 ///
200 /// \return Memberwise division by \a right
201 ///
202 ////////////////////////////////////////////////////////////
203 template <typename T>
204 Vector3<T> operator /(const Vector3<T>& left, T right);
205
206 ////////////////////////////////////////////////////////////
207 /// \relates Vector3
208 /// \brief Overload of binary operator /=
209 ///
210 /// This operator performs a memberwise division by \a right,
211 /// and assigns the result to \a left.
212 ///
213 /// \param left  Left operand (a vector)
214 /// \param right Right operand (a scalar value)
215 ///
216 /// \return Reference to \a left
217 ///
218 ////////////////////////////////////////////////////////////
219 template <typename T>
220 Vector3<T>& operator /=(Vector3<T>& left, T right);
221
222 ////////////////////////////////////////////////////////////
223 /// \relates Vector3
224 /// \brief Overload of binary operator ==
225 ///
226 /// This operator compares strict equality between two vectors.
227 ///
228 /// \param left  Left operand (a vector)
229 /// \param right Right operand (a vector)
230 ///
231 /// \return True if \a left is equal to \a right
232 ///
233 ////////////////////////////////////////////////////////////
234 template <typename T>
235 bool operator ==(const Vector3<T>& left, const Vector3<T>& right);
236
237 ////////////////////////////////////////////////////////////
238 /// \relates Vector3
239 /// \brief Overload of binary operator !=
240 ///
241 /// This operator compares strict difference between two vectors.
242 ///
243 /// \param left  Left operand (a vector)
244 /// \param right Right operand (a vector)
245 ///
246 /// \return True if \a left is not equal to \a right
247 ///
248 ////////////////////////////////////////////////////////////
249 template <typename T>
250 bool operator !=(const Vector3<T>& left, const Vector3<T>& right);
251
252 #include <SFML/System/Vector3.inl>
253
254 // Define the most common types
255 typedef Vector3<int>   Vector3i;
256 typedef Vector3<float> Vector3f;
257
258 } // namespace sf
259
260
261 #endif // SFML_VECTOR3_HPP
262
263
264 ////////////////////////////////////////////////////////////
265 /// \class sf::Vector3
266 /// \ingroup system
267 ///
268 /// sf::Vector3 is a simple class that defines a mathematical
269 /// vector with three coordinates (x, y and z). It can be used to
270 /// represent anything that has three dimensions: a size, a point,
271 /// a velocity, etc.
272 ///
273 /// The template parameter T is the type of the coordinates. It
274 /// can be any type that supports arithmetic operations (+, -, /, *)
275 /// and comparisons (==, !=), for example int or float.
276 ///
277 /// You generally don't have to care about the templated form (sf::Vector3<T>),
278 /// the most common specializations have special typedefs:
279 /// \li sf::Vector3<float> is sf::Vector3f
280 /// \li sf::Vector3<int> is sf::Vector3i
281 ///
282 /// The sf::Vector3 class has a small and simple interface, its x and y members
283 /// can be accessed directly (there are no accessors like setX(), getX()) and it
284 /// contains no mathematical function like dot product, cross product, length, etc.
285 ///
286 /// Usage example:
287 /// \code
288 /// sf::Vector3f v1(16.5f, 24.f, -8.2f);
289 /// v1.x = 18.2f;
290 /// float y = v1.y;
291 /// float z = v1.z;
292 ///
293 /// sf::Vector3f v2 = v1 * 5.f;
294 /// sf::Vector3f v3;
295 /// v3 = v1 + v2;
296 ///
297 /// bool different = (v2 != v3);
298 /// \endcode
299 ///
300 /// Note: for 2-dimensional vectors, see sf::Vector2.
301 ///
302 ////////////////////////////////////////////////////////////