Vector3.inl
1 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2009 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 //
24 
25 
29 template <typename T>
31 x(0),
32 y(0),
33 z(0)
34 {
35 
36 }
37 
38 
42 template <typename T>
43 Vector3<T>::Vector3(T X, T Y, T Z) :
44 x(X),
45 y(Y),
46 z(Z)
47 {
48 
49 }
50 
51 
55 template <typename T>
56 Vector3<T> operator -(const Vector3<T>& V)
57 {
58  return Vector3<T>(-V.x, -V.y, -V.z);
59 }
60 
61 
65 template <typename T>
66 Vector3<T>& operator +=(Vector3<T>& V1, const Vector3<T>& V2)
67 {
68  V1.x += V2.x;
69  V1.y += V2.y;
70  V1.z += V2.z;
71 
72  return V1;
73 }
74 
75 
79 template <typename T>
80 Vector3<T>& operator -=(Vector3<T>& V1, const Vector3<T>& V2)
81 {
82  V1.x -= V2.x;
83  V1.y -= V2.y;
84  V1.z -= V2.z;
85 
86  return V1;
87 }
88 
89 
93 template <typename T>
94 Vector3<T> operator +(const Vector3<T>& V1, const Vector3<T>& V2)
95 {
96  return Vector3<T>(V1.x + V2.x, V1.y + V2.y, V1.z + V2.z);
97 }
98 
99 
103 template <typename T>
104 Vector3<T> operator -(const Vector3<T>& V1, const Vector3<T>& V2)
105 {
106  return Vector3<T>(V1.x - V2.x, V1.y - V2.y, V1.z - V2.z);
107 }
108 
109 
113 template <typename T>
114 Vector3<T> operator *(const Vector3<T>& V, T X)
115 {
116  return Vector3<T>(V.x * X, V.y * X, V.z * X);
117 }
118 
119 
123 template <typename T>
124 Vector3<T> operator *(T X, const Vector3<T>& V)
125 {
126  return Vector3<T>(V.x * X, V.y * X, V.z * X);
127 }
128 
129 
133 template <typename T>
134 Vector3<T>& operator *=(Vector3<T>& V, T X)
135 {
136  V.x *= X;
137  V.y *= X;
138  V.z *= X;
139 
140  return V;
141 }
142 
143 
147 template <typename T>
148 Vector3<T> operator /(const Vector3<T>& V, T X)
149 {
150  return Vector3<T>(V.x / X, V.y / X, V.z / X);
151 }
152 
153 
157 template <typename T>
158 Vector3<T>& operator /=(Vector3<T>& V, T X)
159 {
160  V.x /= X;
161  V.y /= X;
162  V.z /= X;
163 
164  return V;
165 }
166 
167 
171 template <typename T>
172 bool operator ==(const Vector3<T>& V1, const Vector3<T>& V2)
173 {
174  return (V1.x == V2.x) && (V1.y == V2.y) && (V1.z == V2.z);
175 }
176 
177 
181 template <typename T>
182 bool operator !=(const Vector3<T>& V1, const Vector3<T>& V2)
183 {
184  return (V1.x != V2.x) || (V1.y != V2.y) || (V1.z != V2.z);
185 }
Vector3 is an utility class for manipulating 3 dimensional vectors.
Definition: Vector3.hpp:37
Vector3()
Default constructor.
Definition: Vector3.inl:30
T x
X coordinate of the vector.
Definition: Vector3.hpp:60