1 ////////////////////////////////////////////////////////////
\r
3 // SFML - Simple and Fast Multimedia Library
\r
4 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
\r
6 // This software is provided 'as-is', without any express or implied warranty.
\r
7 // In no event will the authors be held liable for any damages arising from the use of this software.
\r
9 // Permission is granted to anyone to use this software for any purpose,
\r
10 // including commercial applications, and to alter it and redistribute it freely,
\r
11 // subject to the following restrictions:
\r
13 // 1. The origin of this software must not be misrepresented;
\r
14 // you must not claim that you wrote the original software.
\r
15 // If you use this software in a product, an acknowledgment
\r
16 // in the product documentation would be appreciated but is not required.
\r
18 // 2. Altered source versions must be plainly marked as such,
\r
19 // and must not be misrepresented as being the original software.
\r
21 // 3. This notice may not be removed or altered from any source distribution.
\r
23 ////////////////////////////////////////////////////////////
\r
25 #ifndef SFML_VECTOR3_HPP
\r
26 #define SFML_VECTOR3_HPP
\r
31 ////////////////////////////////////////////////////////////
\r
32 /// Vector3 is an utility class for manipulating 3 dimensional
\r
33 /// vectors. Template parameter defines the type of coordinates
\r
34 /// (integer, float, ...)
\r
35 ////////////////////////////////////////////////////////////
\r
36 template <typename T>
\r
41 ////////////////////////////////////////////////////////////
\r
42 /// Default constructor
\r
44 ////////////////////////////////////////////////////////////
\r
47 ////////////////////////////////////////////////////////////
\r
48 /// Construct the vector from its coordinates
\r
50 /// \param X : X coordinate
\r
51 /// \param Y : Y coordinate
\r
52 /// \param Z : Z coordinate
\r
54 ////////////////////////////////////////////////////////////
\r
55 Vector3(T X, T Y, T Z);
\r
57 ////////////////////////////////////////////////////////////
\r
59 ////////////////////////////////////////////////////////////
\r
60 T x; ///< X coordinate of the vector
\r
61 T y; ///< Y coordinate of the vector
\r
62 T z; ///< Z coordinate of the vector
\r
65 ////////////////////////////////////////////////////////////
\r
66 /// Operator - overload ; returns the opposite of a vector
\r
68 /// \param V : Vector to negate
\r
72 ////////////////////////////////////////////////////////////
\r
73 template <typename T>
\r
74 Vector3<T> operator -(const Vector3<T>& V);
\r
76 ////////////////////////////////////////////////////////////
\r
77 /// Operator += overload ; add two vectors and assign to the first op
\r
79 /// \param V1 : First vector
\r
80 /// \param V2 : Second vector
\r
84 ////////////////////////////////////////////////////////////
\r
85 template <typename T>
\r
86 Vector3<T>& operator +=(Vector3<T>& V1, const Vector3<T>& V2);
\r
88 ////////////////////////////////////////////////////////////
\r
89 /// Operator -= overload ; subtract two vectors and assign to the first op
\r
91 /// \param V1 : First vector
\r
92 /// \param V2 : Second vector
\r
96 ////////////////////////////////////////////////////////////
\r
97 template <typename T>
\r
98 Vector3<T>& operator -=(Vector3<T>& V1, const Vector3<T>& V2);
\r
100 ////////////////////////////////////////////////////////////
\r
101 /// Operator + overload ; adds two vectors
\r
103 /// \param V1 : First vector
\r
104 /// \param V2 : Second vector
\r
106 /// \return V1 + V2
\r
108 ////////////////////////////////////////////////////////////
\r
109 template <typename T>
\r
110 Vector3<T> operator +(const Vector3<T>& V1, const Vector3<T>& V2);
\r
112 ////////////////////////////////////////////////////////////
\r
113 /// Operator - overload ; subtracts two vectors
\r
115 /// \param V1 : First vector
\r
116 /// \param V2 : Second vector
\r
118 /// \return V1 - V2
\r
120 ////////////////////////////////////////////////////////////
\r
121 template <typename T>
\r
122 Vector3<T> operator -(const Vector3<T>& V1, const Vector3<T>& V2);
\r
124 ////////////////////////////////////////////////////////////
\r
125 /// Operator * overload ; multiply a vector by a scalar value
\r
127 /// \param V : Vector
\r
128 /// \param X : Scalar value
\r
132 ////////////////////////////////////////////////////////////
\r
133 template <typename T>
\r
134 Vector3<T> operator *(const Vector3<T>& V, T X);
\r
136 ////////////////////////////////////////////////////////////
\r
137 /// Operator * overload ; multiply a scalar value by a vector
\r
139 /// \param X : Scalar value
\r
140 /// \param V : Vector
\r
144 ////////////////////////////////////////////////////////////
\r
145 template <typename T>
\r
146 Vector3<T> operator *(T X, const Vector3<T>& V);
\r
148 ////////////////////////////////////////////////////////////
\r
149 /// Operator *= overload ; multiply-assign a vector by a scalar value
\r
151 /// \param V : Vector
\r
152 /// \param X : Scalar value
\r
156 ////////////////////////////////////////////////////////////
\r
157 template <typename T>
\r
158 Vector3<T>& operator *=(Vector3<T>& V, T X);
\r
160 ////////////////////////////////////////////////////////////
\r
161 /// Operator / overload ; divide a vector by a scalar value
\r
163 /// \param V : Vector
\r
164 /// \param X : Scalar value
\r
168 ////////////////////////////////////////////////////////////
\r
169 template <typename T>
\r
170 Vector3<T> operator /(const Vector3<T>& V, T X);
\r
172 ////////////////////////////////////////////////////////////
\r
173 /// Operator /= overload ; divide-assign a vector by a scalar value
\r
175 /// \param V : Vector
\r
176 /// \param X : Scalar value
\r
180 ////////////////////////////////////////////////////////////
\r
181 template <typename T>
\r
182 Vector3<T>& operator /=(Vector3<T>& V, T X);
\r
184 ////////////////////////////////////////////////////////////
\r
185 /// Operator == overload ; compares the equality of two vectors
\r
187 /// \param V1 : First vector
\r
188 /// \param V2 : Second vector
\r
190 /// \return True if V1 is equal to V2
\r
192 ////////////////////////////////////////////////////////////
\r
193 template <typename T>
\r
194 bool operator ==(const Vector3<T>& V1, const Vector3<T>& V2);
\r
196 ////////////////////////////////////////////////////////////
\r
197 /// Operator != overload ; compares the difference of two vectors
\r
199 /// \param V1 : First vector
\r
200 /// \param V2 : Second vector
\r
202 /// \return True if V1 is different than V2
\r
204 ////////////////////////////////////////////////////////////
\r
205 template <typename T>
\r
206 bool operator !=(const Vector3<T>& V1, const Vector3<T>& V2);
\r
208 #include <SFML/System/Vector3.inl>
\r
210 // Define the most common types
\r
211 typedef Vector3<int> Vector3i;
\r
212 typedef Vector3<float> Vector3f;
\r
217 #endif // SFML_VECTOR3_HPP
\r