]> git.sesse.net Git - casparcg/blob - SFML-1.6/include/SFML/System/Vector3.hpp
(no commit message)
[casparcg] / SFML-1.6 / include / SFML / System / Vector3.hpp
1 ////////////////////////////////////////////////////////////\r
2 //\r
3 // SFML - Simple and Fast Multimedia Library\r
4 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)\r
5 //\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
8 //\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
12 //\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
17 //\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
20 //\r
21 // 3. This notice may not be removed or altered from any source distribution.\r
22 //\r
23 ////////////////////////////////////////////////////////////\r
24 \r
25 #ifndef SFML_VECTOR3_HPP\r
26 #define SFML_VECTOR3_HPP\r
27 \r
28 \r
29 namespace sf\r
30 {\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
37 class Vector3\r
38 {\r
39 public :\r
40 \r
41     ////////////////////////////////////////////////////////////\r
42     /// Default constructor\r
43     ///\r
44     ////////////////////////////////////////////////////////////\r
45     Vector3();\r
46 \r
47     ////////////////////////////////////////////////////////////\r
48     /// Construct the vector from its coordinates\r
49     ///\r
50     /// \param X : X coordinate\r
51     /// \param Y : Y coordinate\r
52     /// \param Z : Z coordinate\r
53     ///\r
54     ////////////////////////////////////////////////////////////\r
55     Vector3(T X, T Y, T Z);\r
56 \r
57     ////////////////////////////////////////////////////////////\r
58     // Member data\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
63 };\r
64 \r
65 ////////////////////////////////////////////////////////////\r
66 /// Operator - overload ; returns the opposite of a vector\r
67 ///\r
68 /// \param V : Vector to negate\r
69 ///\r
70 /// \return -V\r
71 ///\r
72 ////////////////////////////////////////////////////////////\r
73 template <typename T>\r
74 Vector3<T> operator -(const Vector3<T>& V);\r
75 \r
76 ////////////////////////////////////////////////////////////\r
77 /// Operator += overload ; add two vectors and assign to the first op\r
78 ///\r
79 /// \param V1 : First vector\r
80 /// \param V2 : Second vector\r
81 ///\r
82 /// \return V1 + V2\r
83 ///\r
84 ////////////////////////////////////////////////////////////\r
85 template <typename T>\r
86 Vector3<T>& operator +=(Vector3<T>& V1, const Vector3<T>& V2);\r
87 \r
88 ////////////////////////////////////////////////////////////\r
89 /// Operator -= overload ; subtract two vectors and assign to the first op\r
90 ///\r
91 /// \param V1 : First vector\r
92 /// \param V2 : Second vector\r
93 ///\r
94 /// \return V1 - V2\r
95 ///\r
96 ////////////////////////////////////////////////////////////\r
97 template <typename T>\r
98 Vector3<T>& operator -=(Vector3<T>& V1, const Vector3<T>& V2);\r
99 \r
100 ////////////////////////////////////////////////////////////\r
101 /// Operator + overload ; adds two vectors\r
102 ///\r
103 /// \param V1 : First vector\r
104 /// \param V2 : Second vector\r
105 ///\r
106 /// \return V1 + V2\r
107 ///\r
108 ////////////////////////////////////////////////////////////\r
109 template <typename T>\r
110 Vector3<T> operator +(const Vector3<T>& V1, const Vector3<T>& V2);\r
111 \r
112 ////////////////////////////////////////////////////////////\r
113 /// Operator - overload ; subtracts two vectors\r
114 ///\r
115 /// \param V1 : First vector\r
116 /// \param V2 : Second vector\r
117 ///\r
118 /// \return V1 - V2\r
119 ///\r
120 ////////////////////////////////////////////////////////////\r
121 template <typename T>\r
122 Vector3<T> operator -(const Vector3<T>& V1, const Vector3<T>& V2);\r
123 \r
124 ////////////////////////////////////////////////////////////\r
125 /// Operator * overload ; multiply a vector by a scalar value\r
126 ///\r
127 /// \param V : Vector\r
128 /// \param X : Scalar value\r
129 ///\r
130 /// \return V * X\r
131 ///\r
132 ////////////////////////////////////////////////////////////\r
133 template <typename T>\r
134 Vector3<T> operator *(const Vector3<T>& V, T X);\r
135 \r
136 ////////////////////////////////////////////////////////////\r
137 /// Operator * overload ; multiply a scalar value by a vector\r
138 ///\r
139 /// \param X : Scalar value\r
140 /// \param V : Vector\r
141 ///\r
142 /// \return X * V\r
143 ///\r
144 ////////////////////////////////////////////////////////////\r
145 template <typename T>\r
146 Vector3<T> operator *(T X, const Vector3<T>& V);\r
147 \r
148 ////////////////////////////////////////////////////////////\r
149 /// Operator *= overload ; multiply-assign a vector by a scalar value\r
150 ///\r
151 /// \param V : Vector\r
152 /// \param X : Scalar value\r
153 ///\r
154 /// \return V * X\r
155 ///\r
156 ////////////////////////////////////////////////////////////\r
157 template <typename T>\r
158 Vector3<T>& operator *=(Vector3<T>& V, T X);\r
159 \r
160 ////////////////////////////////////////////////////////////\r
161 /// Operator / overload ; divide a vector by a scalar value\r
162 ///\r
163 /// \param V : Vector\r
164 /// \param X : Scalar value\r
165 ///\r
166 /// \return V / X\r
167 ///\r
168 ////////////////////////////////////////////////////////////\r
169 template <typename T>\r
170 Vector3<T> operator /(const Vector3<T>& V, T X);\r
171 \r
172 ////////////////////////////////////////////////////////////\r
173 /// Operator /= overload ; divide-assign a vector by a scalar value\r
174 ///\r
175 /// \param V : Vector\r
176 /// \param X : Scalar value\r
177 ///\r
178 /// \return V / X\r
179 ///\r
180 ////////////////////////////////////////////////////////////\r
181 template <typename T>\r
182 Vector3<T>& operator /=(Vector3<T>& V, T X);\r
183 \r
184 ////////////////////////////////////////////////////////////\r
185 /// Operator == overload ; compares the equality of two vectors\r
186 ///\r
187 /// \param V1 : First vector\r
188 /// \param V2 : Second vector\r
189 ///\r
190 /// \return True if V1 is equal to V2\r
191 ///\r
192 ////////////////////////////////////////////////////////////\r
193 template <typename T>\r
194 bool operator ==(const Vector3<T>& V1, const Vector3<T>& V2);\r
195 \r
196 ////////////////////////////////////////////////////////////\r
197 /// Operator != overload ; compares the difference of two vectors\r
198 ///\r
199 /// \param V1 : First vector\r
200 /// \param V2 : Second vector\r
201 ///\r
202 /// \return True if V1 is different than V2\r
203 ///\r
204 ////////////////////////////////////////////////////////////\r
205 template <typename T>\r
206 bool operator !=(const Vector3<T>& V1, const Vector3<T>& V2);\r
207 \r
208 #include <SFML/System/Vector3.inl>\r
209 \r
210 // Define the most common types\r
211 typedef Vector3<int>   Vector3i;\r
212 typedef Vector3<float> Vector3f;\r
213 \r
214 } // namespace sf\r
215 \r
216 \r
217 #endif // SFML_VECTOR3_HPP\r