2020-11-22 23:25:22 -06:00
|
|
|
#include "tempest/vector/C3Vector.hpp"
|
2020-11-26 10:48:52 -06:00
|
|
|
#include "tempest/Math.hpp"
|
2020-11-22 23:25:22 -06:00
|
|
|
|
|
|
|
|
C3Vector& C3Vector::operator*=(float a) {
|
|
|
|
|
this->x *= a;
|
|
|
|
|
this->y *= a;
|
|
|
|
|
this->z *= a;
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-26 10:48:52 -06:00
|
|
|
float C3Vector::Mag() const {
|
|
|
|
|
return CMath::sqrt(this->SquaredMag());
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-26 10:59:42 -06:00
|
|
|
void C3Vector::Normalize() {
|
|
|
|
|
this->operator*=(1.0f / this->Mag());
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-22 23:25:22 -06:00
|
|
|
float C3Vector::SquaredMag() const {
|
|
|
|
|
return this->x * this->x + this->y * this->y + this->z * this->z;
|
|
|
|
|
}
|
2020-11-26 11:38:37 -06:00
|
|
|
|
|
|
|
|
C3Vector operator+(const C3Vector& l, const C3Vector& r) {
|
|
|
|
|
float x = l.x + r.x;
|
|
|
|
|
float y = l.y + r.y;
|
|
|
|
|
float z = l.z + r.z;
|
|
|
|
|
|
|
|
|
|
return { x, y, z };
|
|
|
|
|
}
|
2020-11-26 11:41:04 -06:00
|
|
|
|
|
|
|
|
bool operator!=(const C3Vector& l, const C3Vector& r) {
|
|
|
|
|
return l.x != r.x || l.y != r.y || l.z != r.z;
|
|
|
|
|
}
|