#include using std::initializer_list; namespace _3D { template struct Vector3D { T x, y, z; Vector3D() { this->zero(); } Vector3D(T xInit, T yInit, T zInit) : x(xInit), y(yInit), z(zInit) {} Vector3D(initializer_list coordinates) { auto it = coordinates.begin(); x = *(it++); y = *(it++); z = *it; } template Vector3D(const Vector3D& vec) : x(static_cast(vec.x)), y(static_cast(vec.y)), z(static_cast(vec.z)) {} Vector3D &operator+=(const Vector3D &vec) noexcept { x += vec.x; y += vec.y; z += vec.z; return *this; } Vector3D &operator-=(const Vector3D &vec) noexcept { x -= vec.x; y -= vec.y; z -= vec.z; return *this; } Vector3D &operator*=(const Vector3D &vec) noexcept { x *= vec.x; y *= vec.y; z *= vec.z; return *this; } Vector3D &operator/=(const Vector3D &vec) noexcept { x /= vec.x; y /= vec.y; z /= vec.z; return *this; } Vector3D operator*(const T &i) noexcept { return Vector2D(x * i, y * i, z * i); } Vector3D operator/(const T &i) noexcept { return Vector2D(x / i, y / i, z / i); } Vector3D &zero() noexcept { x = static_cast(0); y = static_cast(0); z = static_cast(0); return *this; } }; template Vector3D operator+(const Vector3D &v1, const Vector3D &v2) { return Vector3D(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); } template Vector3D operator-(const Vector3D &v1, const Vector3D &v2) { return Vector3D(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); } template Vector3D operator*(const Vector3D &v1, const Vector3D &v2) { return Vector3D(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z); } template Vector3D operator/(const Vector3D &v1, const Vector3D &v2) { return Vector3D(v1.x / v2.x, v1.y / v2.y, v1.z / v2.z); } }