Vector3.inl
1
2//
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
29template <typename T>
30Vector3<T>::Vector3() :
31x(0),
32y(0),
33z(0)
34{
35
36}
37
38
42template <typename T>
43Vector3<T>::Vector3(T X, T Y, T Z) :
44x(X),
45y(Y),
46z(Z)
47{
48
49}
50
51
55template <typename T>
56Vector3<T> operator -(const Vector3<T>& V)
57{
58 return Vector3<T>(-V.x, -V.y, -V.z);
59}
60
61
65template <typename T>
66Vector3<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
79template <typename T>
80Vector3<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
93template <typename T>
94Vector3<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
103template <typename T>
104Vector3<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
113template <typename T>
114Vector3<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
123template <typename T>
124Vector3<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
133template <typename T>
134Vector3<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
147template <typename T>
148Vector3<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
157template <typename T>
158Vector3<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
171template <typename T>
172bool 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
181template <typename T>
182bool 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}