Wip: Add basic vector math
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
#pragma once
|
||||
#include <math.h>
|
||||
#include <utility>
|
||||
|
||||
class Vector3 {
|
||||
private:
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
|
||||
public:
|
||||
float X() const { return x; }
|
||||
float Y() const { return y; }
|
||||
float Z() const { return z; }
|
||||
|
||||
|
||||
Vector3() {
|
||||
x = 0.0f;
|
||||
y = 0.0f;
|
||||
z = 0.0f;
|
||||
}
|
||||
|
||||
Vector3(float xDat, float yDat, float zDat) {
|
||||
x = xDat;
|
||||
y = yDat;
|
||||
z = zDat;
|
||||
}
|
||||
|
||||
Vector3 Zero() { return Vector3(); }
|
||||
Vector3 operator+(const Vector3 &rhs) { return Vector3(x + rhs.x, y + rhs.y, z + rhs.z); }
|
||||
|
||||
Vector3 &operator=(Vector3 &rhs) {
|
||||
swap(*this, rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline friend void swap(Vector3 &lhs, Vector3 &rhs) noexcept {
|
||||
using std::swap;
|
||||
swap(lhs.x, rhs.x);
|
||||
swap(lhs.y, rhs.y);
|
||||
swap(lhs.z, rhs.z);
|
||||
}
|
||||
};
|
||||
|
||||
class Vector3I {
|
||||
private:
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
|
||||
public:
|
||||
int X() const { return x; }
|
||||
int Y() const { return y; }
|
||||
int Z() const { return z; }
|
||||
|
||||
|
||||
Vector3I() {
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
}
|
||||
|
||||
Vector3I(int xDat, int yDat, int zDat) {
|
||||
x = xDat;
|
||||
y = yDat;
|
||||
z = zDat;
|
||||
}
|
||||
|
||||
Vector3I Zero() { return Vector3I(); }
|
||||
Vector3I operator+(const Vector3I &rhs) { return Vector3I(x + rhs.x, y + rhs.y, z + rhs.z); }
|
||||
Vector3I &operator=(Vector3I &rhs) {
|
||||
swap(*this, rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline friend void swap(Vector3I &lhs, Vector3I &rhs) noexcept {
|
||||
using std::swap;
|
||||
swap(lhs.x, rhs.x);
|
||||
swap(lhs.y, rhs.y);
|
||||
swap(lhs.z, rhs.z);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user