#include "vector.hh" Vector &Vector::operator += (const Vector &other){ this->x += other.x; this->y += other.y; this->z += other.z; return *this; } Vector Vector::operator + (const Vector &other) const{ return Vector(*this) += other; } Vector &Vector::operator -= (const Vector &other){ return *this += other.scale(-1); } Vector Vector::operator - (const Vector &other) const{ return Vector(*this) -= other; } Vector Vector::cross(const Vector &other) const{ return Vector(this->y * other.z - this->z * other.y, this->z * other.x - this->x * other.z, this->x * other.y - this->y * other.x); } float Vector::dot(const Vector &other) const{ return this->x * other.x + this->y * other.y + this->z * other.z; } float Vector::magnitude(void) const{ return this->dot(*this); } Vector Vector::scale(float amount) const{ return Vector(this->x * amount, this->y * amount, this->z * amount); }