Warning, /include/SFML/System/Vector3.inl is written in an unsupported language. File is not indexed.
0001 ////////////////////////////////////////////////////////////
0002 //
0003 // SFML - Simple and Fast Multimedia Library
0004 // Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org)
0005 //
0006 // This software is provided 'as-is', without any express or implied warranty.
0007 // In no event will the authors be held liable for any damages arising from the use of this software.
0008 //
0009 // Permission is granted to anyone to use this software for any purpose,
0010 // including commercial applications, and to alter it and redistribute it freely,
0011 // subject to the following restrictions:
0012 //
0013 // 1. The origin of this software must not be misrepresented;
0014 // you must not claim that you wrote the original software.
0015 // If you use this software in a product, an acknowledgment
0016 // in the product documentation would be appreciated but is not required.
0017 //
0018 // 2. Altered source versions must be plainly marked as such,
0019 // and must not be misrepresented as being the original software.
0020 //
0021 // 3. This notice may not be removed or altered from any source distribution.
0022 //
0023 ////////////////////////////////////////////////////////////
0024
0025
0026 ////////////////////////////////////////////////////////////
0027 template <typename T>
0028 inline Vector3<T>::Vector3() :
0029 x(0),
0030 y(0),
0031 z(0)
0032 {
0033
0034 }
0035
0036
0037 ////////////////////////////////////////////////////////////
0038 template <typename T>
0039 inline Vector3<T>::Vector3(T X, T Y, T Z) :
0040 x(X),
0041 y(Y),
0042 z(Z)
0043 {
0044
0045 }
0046
0047
0048 ////////////////////////////////////////////////////////////
0049 template <typename T>
0050 template <typename U>
0051 inline Vector3<T>::Vector3(const Vector3<U>& vector) :
0052 x(static_cast<T>(vector.x)),
0053 y(static_cast<T>(vector.y)),
0054 z(static_cast<T>(vector.z))
0055 {
0056 }
0057
0058
0059 ////////////////////////////////////////////////////////////
0060 template <typename T>
0061 inline Vector3<T> operator -(const Vector3<T>& left)
0062 {
0063 return Vector3<T>(-left.x, -left.y, -left.z);
0064 }
0065
0066
0067 ////////////////////////////////////////////////////////////
0068 template <typename T>
0069 inline Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right)
0070 {
0071 left.x += right.x;
0072 left.y += right.y;
0073 left.z += right.z;
0074
0075 return left;
0076 }
0077
0078
0079 ////////////////////////////////////////////////////////////
0080 template <typename T>
0081 inline Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right)
0082 {
0083 left.x -= right.x;
0084 left.y -= right.y;
0085 left.z -= right.z;
0086
0087 return left;
0088 }
0089
0090
0091 ////////////////////////////////////////////////////////////
0092 template <typename T>
0093 inline Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right)
0094 {
0095 return Vector3<T>(left.x + right.x, left.y + right.y, left.z + right.z);
0096 }
0097
0098
0099 ////////////////////////////////////////////////////////////
0100 template <typename T>
0101 inline Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right)
0102 {
0103 return Vector3<T>(left.x - right.x, left.y - right.y, left.z - right.z);
0104 }
0105
0106
0107 ////////////////////////////////////////////////////////////
0108 template <typename T>
0109 inline Vector3<T> operator *(const Vector3<T>& left, T right)
0110 {
0111 return Vector3<T>(left.x * right, left.y * right, left.z * right);
0112 }
0113
0114
0115 ////////////////////////////////////////////////////////////
0116 template <typename T>
0117 inline Vector3<T> operator *(T left, const Vector3<T>& right)
0118 {
0119 return Vector3<T>(right.x * left, right.y * left, right.z * left);
0120 }
0121
0122
0123 ////////////////////////////////////////////////////////////
0124 template <typename T>
0125 inline Vector3<T>& operator *=(Vector3<T>& left, T right)
0126 {
0127 left.x *= right;
0128 left.y *= right;
0129 left.z *= right;
0130
0131 return left;
0132 }
0133
0134
0135 ////////////////////////////////////////////////////////////
0136 template <typename T>
0137 inline Vector3<T> operator /(const Vector3<T>& left, T right)
0138 {
0139 return Vector3<T>(left.x / right, left.y / right, left.z / right);
0140 }
0141
0142
0143 ////////////////////////////////////////////////////////////
0144 template <typename T>
0145 inline Vector3<T>& operator /=(Vector3<T>& left, T right)
0146 {
0147 left.x /= right;
0148 left.y /= right;
0149 left.z /= right;
0150
0151 return left;
0152 }
0153
0154
0155 ////////////////////////////////////////////////////////////
0156 template <typename T>
0157 inline bool operator ==(const Vector3<T>& left, const Vector3<T>& right)
0158 {
0159 return (left.x == right.x) && (left.y == right.y) && (left.z == right.z);
0160 }
0161
0162
0163 ////////////////////////////////////////////////////////////
0164 template <typename T>
0165 inline bool operator !=(const Vector3<T>& left, const Vector3<T>& right)
0166 {
0167 return (left.x != right.x) || (left.y != right.y) || (left.z != right.z);
0168 }