diff options
Diffstat (limited to 'src/math')
-rw-r--r-- | src/math/vector.cpp | 12 | ||||
-rw-r--r-- | src/math/vector.h | 4 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/math/vector.cpp b/src/math/vector.cpp index 36e813d..306fc3d 100644 --- a/src/math/vector.cpp +++ b/src/math/vector.cpp @@ -87,10 +87,6 @@ Vector3 Vector3::round() const { return { std::round(x), std::round(y), std::round(z) }; } -Vector2 Vector3::xy() const { - return { x, y }; -} - Vector3 Vector3::cross(Vector3 other) const { return { y * other.z - z * other.y, @@ -154,12 +150,16 @@ Vector4 Vector4::round() const { return { std::round(x), std::round(y), std::round(z), std::round(w) }; } +Vector2 Vector4::xy() const { + return { x, y }; +} + Vector3 Vector4::xyz() const { return { x, y, z }; } -Vector3 Vector4::div_by_w() const { - return xyz() / w; +Vector4 Vector4::div_by_w() const { + return {x / w, y / w, z / w, w}; } Vector4 engine::math::operator*(float n, Vector4 other) { diff --git a/src/math/vector.h b/src/math/vector.h index 8f7059a..82e1513 100644 --- a/src/math/vector.h +++ b/src/math/vector.h @@ -36,7 +36,6 @@ class Vector3 { Vector3 operator+(Vector3 other) const; Vector3 operator-(Vector3 other) const; Vector3 round() const; - Vector2 xy() const; Vector3 cross(Vector3 other) const; }; @@ -60,8 +59,9 @@ class Vector4 { Vector4 operator+(Vector4 other) const; Vector4 operator-(Vector4 other) const; Vector4 round() const; + Vector2 xy() const; Vector3 xyz() const; - Vector3 div_by_w() const; + Vector4 div_by_w() const; }; Vector4 operator*(float n, Vector4 other); |