From 48ec7df0fd27fab05c9918e83a3a7da1cc32d7a0 Mon Sep 17 00:00:00 2001 From: vimene Date: Sun, 3 Dec 2023 09:27:32 +0100 Subject: renamed MathVector{2,3,4} to Vector{2,3,4} and Mat4 to Matrix4 in engine::math --- src/math/vector.cpp | 90 ++++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'src/math/vector.cpp') diff --git a/src/math/vector.cpp b/src/math/vector.cpp index aacff86..36e813d 100644 --- a/src/math/vector.cpp +++ b/src/math/vector.cpp @@ -1,97 +1,97 @@ -#include "math/math_vector.h" +#include "math/vector.h" #include using namespace engine::math; -MathVector2::MathVector2() { +Vector2::Vector2() { } -MathVector2::MathVector2(float x, float y) : x{x}, y{y} { +Vector2::Vector2(float x, float y) : x{x}, y{y} { } -bool MathVector2::operator==(MathVector2 other) const { +bool Vector2::operator==(Vector2 other) const { return x == other.x && y == other.y; } -bool MathVector2::operator!=(MathVector2 other) const { +bool Vector2::operator!=(Vector2 other) const { return !(*this == other); } -MathVector2 MathVector2::operator+() const { +Vector2 Vector2::operator+() const { return *this; } -MathVector2 MathVector2::operator-() const { +Vector2 Vector2::operator-() const { return { -x, -y }; } -MathVector2 MathVector2::operator+(MathVector2 other) const { +Vector2 Vector2::operator+(Vector2 other) const { return { x + other.x, y + other.y }; } -MathVector2 MathVector2::operator-(MathVector2 other) const { +Vector2 Vector2::operator-(Vector2 other) const { return *this + (-other); } -float MathVector2::det(MathVector2 other) const { +float Vector2::det(Vector2 other) const { return this->x * other.y - other.x * this->y; } -MathVector2 MathVector2::round() const { +Vector2 Vector2::round() const { return { std::round(x), std::round(y) }; } -MathVector2 engine::math::operator*(float n, MathVector2 other) { +Vector2 engine::math::operator*(float n, Vector2 other) { return { n * other.x, n * other.y }; } -MathVector2 engine::math::operator*(MathVector2 other, float n) { +Vector2 engine::math::operator*(Vector2 other, float n) { return n * other; } -MathVector2 engine::math::operator/(MathVector2 other, float n) { +Vector2 engine::math::operator/(Vector2 other, float n) { return { other.x / n, other.y / n }; } -MathVector3::MathVector3() { +Vector3::Vector3() { } -MathVector3::MathVector3(float x, float y, float z) : x{x}, y{y}, z{z} { +Vector3::Vector3(float x, float y, float z) : x{x}, y{y}, z{z} { } -bool MathVector3::operator==(MathVector3 other) const { +bool Vector3::operator==(Vector3 other) const { return x == other.x && y == other.y && z == other.z; } -bool MathVector3::operator!=(MathVector3 other) const { +bool Vector3::operator!=(Vector3 other) const { return !(*this == other); } -MathVector3 MathVector3::operator+() const { +Vector3 Vector3::operator+() const { return *this; } -MathVector3 MathVector3::operator-() const { +Vector3 Vector3::operator-() const { return { -x, -y, -z }; } -MathVector3 MathVector3::operator+(MathVector3 other) const { +Vector3 Vector3::operator+(Vector3 other) const { return { x + other.x, y + other.y, z + other.z }; } -MathVector3 MathVector3::operator-(MathVector3 other) const { +Vector3 Vector3::operator-(Vector3 other) const { return *this + (-other); } -MathVector3 MathVector3::round() const { +Vector3 Vector3::round() const { return { std::round(x), std::round(y), std::round(z) }; } -MathVector2 MathVector3::xy() const { +Vector2 Vector3::xy() const { return { x, y }; } -MathVector3 MathVector3::cross(MathVector3 other) const { +Vector3 Vector3::cross(Vector3 other) const { return { y * other.z - z * other.y, z * other.x - x * other.z, @@ -99,77 +99,77 @@ MathVector3 MathVector3::cross(MathVector3 other) const { }; } -MathVector3 engine::math::operator*(float n, MathVector3 other) { +Vector3 engine::math::operator*(float n, Vector3 other) { return { n * other.x, n * other.y, n * other.z }; } -MathVector3 engine::math::operator*(MathVector3 other, float n) { +Vector3 engine::math::operator*(Vector3 other, float n) { return n * other; } -MathVector3 engine::math::operator/(MathVector3 other, float n) { +Vector3 engine::math::operator/(Vector3 other, float n) { return { other.x / n, other.y / n, other.z / n }; } -MathVector4::MathVector4() { +Vector4::Vector4() { } -MathVector4::MathVector4(float x, float y, float z, float w) : x{x}, y{y}, z{z}, w{w} { +Vector4::Vector4(float x, float y, float z, float w) : x{x}, y{y}, z{z}, w{w} { } -MathVector4::MathVector4(float x, float y, float z) : x{x}, y{y}, z{z}, w{1.f} { +Vector4::Vector4(float x, float y, float z) : x{x}, y{y}, z{z}, w{1.f} { } -MathVector4::MathVector4(MathVector3 v, float w) : x{v.x}, y{v.y}, z{v.z}, w{w} { +Vector4::Vector4(Vector3 v, float w) : x{v.x}, y{v.y}, z{v.z}, w{w} { } -MathVector4::MathVector4(MathVector3 v) : x{v.x}, y{v.y}, z{v.z}, w{1.f} { +Vector4::Vector4(Vector3 v) : x{v.x}, y{v.y}, z{v.z}, w{1.f} { } -bool MathVector4::operator==(MathVector4 other) const { +bool Vector4::operator==(Vector4 other) const { return x == other.x && y == other.y && z == other.z && w == other.w; } -bool MathVector4::operator!=(MathVector4 other) const { +bool Vector4::operator!=(Vector4 other) const { return !(*this == other); } -MathVector4 MathVector4::operator+() const { +Vector4 Vector4::operator+() const { return *this; } -MathVector4 MathVector4::operator-() const { +Vector4 Vector4::operator-() const { return { -x, -y, -z, -w }; } -MathVector4 MathVector4::operator+(MathVector4 other) const { +Vector4 Vector4::operator+(Vector4 other) const { return { x + other.x, y + other.y, z + other.z, w + other.w }; } -MathVector4 MathVector4::operator-(MathVector4 other) const { +Vector4 Vector4::operator-(Vector4 other) const { return *this + (-other); } -MathVector4 MathVector4::round() const { +Vector4 Vector4::round() const { return { std::round(x), std::round(y), std::round(z), std::round(w) }; } -MathVector3 MathVector4::xyz() const { +Vector3 Vector4::xyz() const { return { x, y, z }; } -MathVector3 MathVector4::div_by_w() const { +Vector3 Vector4::div_by_w() const { return xyz() / w; } -MathVector4 engine::math::operator*(float n, MathVector4 other) { +Vector4 engine::math::operator*(float n, Vector4 other) { return { n * other.x, n * other.y, n * other.z, n * other.w }; } -MathVector4 engine::math::operator*(MathVector4 other, float n) { +Vector4 engine::math::operator*(Vector4 other, float n) { return n * other; } -MathVector4 engine::math::operator/(MathVector4 other, float n) { +Vector4 engine::math::operator/(Vector4 other, float n) { return { other.x / n, other.y / n, other.z / n, other.w / n }; } -- cgit v1.2.3