Onsens  1.0
This is C++ game about bitwise logic.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Vector3.inl
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
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
27template <typename T>
29x(0),
30y(0),
31z(0)
32{
33
34}
35
36
38template <typename T>
39inline Vector3<T>::Vector3(T X, T Y, T Z) :
40x(X),
41y(Y),
42z(Z)
43{
44
45}
46
47
49template <typename T>
50template <typename U>
51inline Vector3<T>::Vector3(const Vector3<U>& vector) :
52x(static_cast<T>(vector.x)),
53y(static_cast<T>(vector.y)),
54z(static_cast<T>(vector.z))
55{
56}
57
58
60template <typename T>
61inline Vector3<T> operator -(const Vector3<T>& left)
62{
63 return Vector3<T>(-left.x, -left.y, -left.z);
64}
65
66
68template <typename T>
69inline Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right)
70{
71 left.x += right.x;
72 left.y += right.y;
73 left.z += right.z;
74
75 return left;
76}
77
78
80template <typename T>
81inline Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right)
82{
83 left.x -= right.x;
84 left.y -= right.y;
85 left.z -= right.z;
86
87 return left;
88}
89
90
92template <typename T>
93inline Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right)
94{
95 return Vector3<T>(left.x + right.x, left.y + right.y, left.z + right.z);
96}
97
98
100template <typename T>
101inline Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right)
102{
103 return Vector3<T>(left.x - right.x, left.y - right.y, left.z - right.z);
104}
105
106
108template <typename T>
109inline Vector3<T> operator *(const Vector3<T>& left, T right)
110{
111 return Vector3<T>(left.x * right, left.y * right, left.z * right);
112}
113
114
116template <typename T>
117inline Vector3<T> operator *(T left, const Vector3<T>& right)
118{
119 return Vector3<T>(right.x * left, right.y * left, right.z * left);
120}
121
122
124template <typename T>
125inline Vector3<T>& operator *=(Vector3<T>& left, T right)
126{
127 left.x *= right;
128 left.y *= right;
129 left.z *= right;
130
131 return left;
132}
133
134
136template <typename T>
137inline Vector3<T> operator /(const Vector3<T>& left, T right)
138{
139 return Vector3<T>(left.x / right, left.y / right, left.z / right);
140}
141
142
144template <typename T>
145inline Vector3<T>& operator /=(Vector3<T>& left, T right)
146{
147 left.x /= right;
148 left.y /= right;
149 left.z /= right;
150
151 return left;
152}
153
154
156template <typename T>
157inline bool operator ==(const Vector3<T>& left, const Vector3<T>& right)
158{
159 return (left.x == right.x) && (left.y == right.y) && (left.z == right.z);
160}
161
162
164template <typename T>
165inline bool operator !=(const Vector3<T>& left, const Vector3<T>& right)
166{
167 return (left.x != right.x) || (left.y != right.y) || (left.z != right.z);
168}
Vector3< T > operator*(const Vector3< T > &left, T right)
Definition: Vector3.inl:109
Vector3< T > operator+(const Vector3< T > &left, const Vector3< T > &right)
Definition: Vector3.inl:93
Vector3< T > & operator/=(Vector3< T > &left, T right)
Definition: Vector3.inl:145
Vector3< T > operator-(const Vector3< T > &left)
Definition: Vector3.inl:61
Vector3< T > & operator-=(Vector3< T > &left, const Vector3< T > &right)
Definition: Vector3.inl:81
Vector3< T > & operator+=(Vector3< T > &left, const Vector3< T > &right)
Definition: Vector3.inl:69
Vector3< T > operator/(const Vector3< T > &left, T right)
Definition: Vector3.inl:137
Vector3< T > & operator*=(Vector3< T > &left, T right)
Definition: Vector3.inl:125
Utility template class for manipulating 3-dimensional vectors.
Definition: Vector3.hpp:38
Vector3()
Default constructor.
SFML_NETWORK_API bool operator==(const IpAddress &left, const IpAddress &right)
Overload of == operator to compare two IP addresses.
SFML_NETWORK_API bool operator!=(const IpAddress &left, const IpAddress &right)
Overload of != operator to compare two IP addresses.