#ifdef VECTOR3D_H_ // since the .cpp file has to be included by the .hpp file this // will evaluate to true #include #include template V3D::V3D(const Matrix<1, 3> &other) { this->x = other.Get(0, 0); this->y = other.Get(0, 1); this->z = other.Get(0, 2); } template V3D::V3D(const Matrix<3, 1> &other) { this->x = other.Get(0, 0); this->y = other.Get(1, 0); this->z = other.Get(2, 0); } template V3D::V3D(const V3D &other) : x(other.x), y(other.y), z(other.z) { static_assert(std::is_arithmetic::value, "Type must be a number"); } template V3D::V3D(Type x, Type y, Type z) : x(x), y(y), z(z) { static_assert(std::is_arithmetic::value, "Type must be a number"); } template template V3D::V3D(const V3D &other) { static_assert(std::is_arithmetic::value, "Type must be a number"); static_assert(std::is_arithmetic::value, "OtherType must be a number"); this->x = static_cast(other.x); this->y = static_cast(other.y); this->z = static_cast(other.z); } template std::array V3D::ToArray() { return {this->x, this->y, this->z}; } template void V3D::operator=(const V3D &other) { this->x = other.x; this->y = other.y; this->z = other.z; } template V3D V3D::operator+(const V3D &other) { return V3D{this->x + other.x, this->y + other.y, this->z + other.z}; } template V3D V3D::operator-(const V3D &other) { return V3D{this->x - other.x, this->y - other.y, this->z - other.z}; } template V3D V3D::operator*(Type scalar) { return V3D{this->x * scalar, this->y * scalar, this->z * scalar}; } template V3D &V3D::operator+=(const V3D &other) { *this = *this + other; return *this; } template V3D &V3D::operator-=(const V3D &other) { *this = *this - other; return *this; } template V3D &V3D::operator/=(Type scalar) { if (scalar == 0) { return *this; } this->x /= scalar; this->y /= scalar; this->z /= scalar; return *this; } template V3D &V3D::operator*=(Type scalar) { this->x *= scalar; this->y *= scalar; this->z *= scalar; return *this; } template bool V3D::operator==(const V3D &other) { return this->x == other.x && this->y == other.y && this->z == other.z; } template float V3D::magnitude() { return std::sqrt(static_cast(this->x * this->x + this->y * this->y + this->z * this->z)); } #endif // VECTOR3D_H_