From 17eb0cd0dc1d068ee238095d453774dcf1036ac6 Mon Sep 17 00:00:00 2001 From: Orange Date: Tue, 13 May 2025 09:47:08 +0300 Subject: [PATCH] improved naming --- include/omath/vector2.hpp | 72 ++++++++++++++++---------------- include/omath/vector3.hpp | 86 ++++++++++++++++++++------------------- include/omath/vector4.hpp | 69 +++++++++++++++---------------- 3 files changed, 115 insertions(+), 112 deletions(-) diff --git a/include/omath/vector2.hpp b/include/omath/vector2.hpp index 0f31bc3..6287131 100644 --- a/include/omath/vector2.hpp +++ b/include/omath/vector2.hpp @@ -30,78 +30,78 @@ namespace omath // Equality operators [[nodiscard]] - constexpr bool operator==(const Vector2& src) const noexcept + constexpr bool operator==(const Vector2& other) const noexcept { - return x == src.x && y == src.y; + return x == other.x && y == other.y; } [[nodiscard]] - constexpr bool operator!=(const Vector2& src) const noexcept + constexpr bool operator!=(const Vector2& other) const noexcept { - return !(*this == src); + return !(*this == other); } // Compound assignment operators - constexpr Vector2& operator+=(const Vector2& v) noexcept + constexpr Vector2& operator+=(const Vector2& other) noexcept { - x += v.x; - y += v.y; + x += other.x; + y += other.y; return *this; } - constexpr Vector2& operator-=(const Vector2& v) noexcept + constexpr Vector2& operator-=(const Vector2& other) noexcept { - x -= v.x; - y -= v.y; + x -= other.x; + y -= other.y; return *this; } - constexpr Vector2& operator*=(const Vector2& v) noexcept + constexpr Vector2& operator*=(const Vector2& other) noexcept { - x *= v.x; - y *= v.y; + x *= other.x; + y *= other.y; return *this; } - constexpr Vector2& operator/=(const Vector2& v) noexcept + constexpr Vector2& operator/=(const Vector2& other) noexcept { - x /= v.x; - y /= v.y; + x /= other.x; + y /= other.y; return *this; } - constexpr Vector2& operator*=(const Type& fl) noexcept + constexpr Vector2& operator*=(const Type& value) noexcept { - x *= fl; - y *= fl; + x *= value; + y *= value; return *this; } - constexpr Vector2& operator/=(const Type& fl) noexcept + constexpr Vector2& operator/=(const Type& value) noexcept { - x /= fl; - y /= fl; + x /= value; + y /= value; return *this; } - constexpr Vector2& operator+=(const Type& fl) noexcept + constexpr Vector2& operator+=(const Type& value) noexcept { - x += fl; - y += fl; + x += value; + y += value; return *this; } - constexpr Vector2& operator-=(const Type& fl) noexcept + constexpr Vector2& operator-=(const Type& value) noexcept { - x -= fl; - y -= fl; + x -= value; + y -= value; return *this; } @@ -164,24 +164,24 @@ namespace omath } // Binary arithmetic operators - [[nodiscard]] constexpr Vector2 operator+(const Vector2& v) const noexcept + [[nodiscard]] constexpr Vector2 operator+(const Vector2& other) const noexcept { - return {x + v.x, y + v.y}; + return {x + other.x, y + other.y}; } - [[nodiscard]] constexpr Vector2 operator-(const Vector2& v) const noexcept + [[nodiscard]] constexpr Vector2 operator-(const Vector2& other) const noexcept { - return {x - v.x, y - v.y}; + return {x - other.x, y - other.y}; } - [[nodiscard]] constexpr Vector2 operator*(const Type& fl) const noexcept + [[nodiscard]] constexpr Vector2 operator*(const Type& value) const noexcept { - return {x * fl, y * fl}; + return {x * value, y * value}; } - [[nodiscard]] constexpr Vector2 operator/(const Type& fl) const noexcept + [[nodiscard]] constexpr Vector2 operator/(const Type& value) const noexcept { - return {x / fl, y / fl}; + return {x / value, y / value}; } // Sum of elements diff --git a/include/omath/vector3.hpp b/include/omath/vector3.hpp index 1f0316b..a4654c0 100644 --- a/include/omath/vector3.hpp +++ b/include/omath/vector3.hpp @@ -29,76 +29,76 @@ namespace omath } constexpr Vector3() noexcept: Vector2() {}; - [[nodiscard]] constexpr bool operator==(const Vector3& src) const noexcept + [[nodiscard]] constexpr bool operator==(const Vector3& other) const noexcept { - return Vector2::operator==(src) && (src.z == z); + return Vector2::operator==(other) && (other.z == z); } - [[nodiscard]] constexpr bool operator!=(const Vector3& src) const noexcept + [[nodiscard]] constexpr bool operator!=(const Vector3& other) const noexcept { - return !(*this == src); + return !(*this == other); } - constexpr Vector3& operator+=(const Vector3& v) noexcept + constexpr Vector3& operator+=(const Vector3& other) noexcept { - Vector2::operator+=(v); - z += v.z; + Vector2::operator+=(other); + z += other.z; return *this; } - constexpr Vector3& operator-=(const Vector3& v) noexcept + constexpr Vector3& operator-=(const Vector3& other) noexcept { - Vector2::operator-=(v); - z -= v.z; + Vector2::operator-=(other); + z -= other.z; return *this; } - constexpr Vector3& operator*=(const float fl) noexcept + constexpr Vector3& operator*=(const Type& value) noexcept { - Vector2::operator*=(fl); - z *= fl; + Vector2::operator*=(value); + z *= value; return *this; } - constexpr Vector3& operator*=(const Vector3& v) noexcept + constexpr Vector3& operator*=(const Vector3& other) noexcept { - Vector2::operator*=(v); - z *= v.z; + Vector2::operator*=(other); + z *= other.z; return *this; } - constexpr Vector3& operator/=(const Vector3& v) noexcept + constexpr Vector3& operator/=(const Vector3& other) noexcept { - Vector2::operator/=(v); - z /= v.z; + Vector2::operator/=(other); + z /= other.z; return *this; } - constexpr Vector3& operator+=(const float fl) noexcept + constexpr Vector3& operator+=(const Type& value) noexcept { - Vector2::operator+=(fl); - z += fl; + Vector2::operator+=(value); + z += value; return *this; } - constexpr Vector3& operator/=(const float fl) noexcept + constexpr Vector3& operator/=(const Type& value) noexcept { - Vector2::operator/=(fl); - z /= fl; + Vector2::operator/=(value); + z /= value; return *this; } - constexpr Vector3& operator-=(const float fl) noexcept + constexpr Vector3& operator-=(const Type& value) noexcept { - Vector2::operator-=(fl); - z -= fl; + Vector2::operator-=(value); + z -= value; return *this; } @@ -175,40 +175,42 @@ namespace omath return {-this->x, -this->y, -z}; } - [[nodiscard]] constexpr Vector3 operator+(const Vector3& v) const noexcept + [[nodiscard]] constexpr Vector3 operator+(const Vector3& other) const noexcept { - return {this->x + v.x, this->y + v.y, z + v.z}; + return {this->x + other.x, this->y + other.y, z + other.z}; } - [[nodiscard]] constexpr Vector3 operator-(const Vector3& v) const noexcept + [[nodiscard]] constexpr Vector3 operator-(const Vector3& other) const noexcept { - return {this->x - v.x, this->y - v.y, z - v.z}; + return {this->x - other.x, this->y - other.y, z - other.z}; } - [[nodiscard]] constexpr Vector3 operator*(const Type& fl) const noexcept + [[nodiscard]] constexpr Vector3 operator*(const Type& value) const noexcept { - return {this->x * fl, this->y * fl, z * fl}; + return {this->x * value, this->y * value, z * value}; } - [[nodiscard]] constexpr Vector3 operator*(const Vector3& v) const noexcept + [[nodiscard]] constexpr Vector3 operator*(const Vector3& other) const noexcept { - return {this->x * v.x, this->y * v.y, z * v.z}; + return {this->x * other.x, this->y * other.y, z * other.z}; } - [[nodiscard]] constexpr Vector3 operator/(const Type& fl) const noexcept + [[nodiscard]] constexpr Vector3 operator/(const Type& value) const noexcept { - return {this->x / fl, this->y / fl, z / fl}; + return {this->x / value, this->y / value, z / value}; } - [[nodiscard]] constexpr Vector3 operator/(const Vector3& v) const noexcept + [[nodiscard]] constexpr Vector3 operator/(const Vector3& other) const noexcept { - return {this->x / v.x, this->y / v.y, z / v.z}; + return {this->x / other.x, this->y / other.y, z / other.z}; } - [[nodiscard]] constexpr Vector3 cross(const Vector3& v) const noexcept + [[nodiscard]] constexpr Vector3 cross(const Vector3& other) const noexcept { - return {this->y * v.z - z * v.y, z * v.x - this->x * v.z, this->x * v.y - this->y * v.x}; + return {this->y * other.z - z * other.y, z * other.x - this->x * other.z, + this->x * other.y - this->y * other.x}; } + [[nodiscard]] constexpr Type sum() const noexcept { return sum_2d() + z; diff --git a/include/omath/vector4.hpp b/include/omath/vector4.hpp index dfc403f..9e54fbb 100644 --- a/include/omath/vector4.hpp +++ b/include/omath/vector4.hpp @@ -9,6 +9,7 @@ namespace omath { template + requires std::is_arithmetic_v class Vector4 : public Vector3 { public: @@ -20,61 +21,61 @@ namespace omath constexpr Vector4() noexcept : Vector3(), w(0) {}; [[nodiscard]] - constexpr bool operator==(const Vector4& src) const noexcept + constexpr bool operator==(const Vector4& other) const noexcept { - return Vector3::operator==(src) && w == src.w; + return Vector3::operator==(other) && w == other.w; } [[nodiscard]] - constexpr bool operator!=(const Vector4& src) const noexcept + constexpr bool operator!=(const Vector4& other) const noexcept { - return !(*this == src); + return !(*this == other); } - constexpr Vector4& operator+=(const Vector4& v) noexcept + constexpr Vector4& operator+=(const Vector4& other) noexcept { - Vector3::operator+=(v); - w += v.w; + Vector3::operator+=(other); + w += other.w; return *this; } - constexpr Vector4& operator-=(const Vector4& v) noexcept + constexpr Vector4& operator-=(const Vector4& other) noexcept { - Vector3::operator-=(v); - w -= v.w; + Vector3::operator-=(other); + w -= other.w; return *this; } - constexpr Vector4& operator*=(const Type& scalar) noexcept + constexpr Vector4& operator*=(const Type& value) noexcept { - Vector3::operator*=(scalar); - w *= scalar; + Vector3::operator*=(value); + w *= value; return *this; } - constexpr Vector4& operator*=(const Vector4& v) noexcept + constexpr Vector4& operator*=(const Vector4& other) noexcept { - Vector3::operator*=(v); - w *= v.w; + Vector3::operator*=(other); + w *= other.w; return *this; } - constexpr Vector4& operator/=(const Type& scalar) noexcept + constexpr Vector4& operator/=(const Type& value) noexcept { - Vector3::operator/=(scalar); - w /= scalar; + Vector3::operator/=(value); + w /= value; return *this; } - constexpr Vector4& operator/=(const Vector4& v) noexcept + constexpr Vector4& operator/=(const Vector4& other) noexcept { - Vector3::operator/=(v); - w /= v.w; + Vector3::operator/=(other); + w /= other.w; return *this; } @@ -116,39 +117,39 @@ namespace omath } [[nodiscard]] - constexpr Vector4 operator+(const Vector4& v) const noexcept + constexpr Vector4 operator+(const Vector4& other) const noexcept { - return {this->x + v.x, this->y + v.y, this->z + v.z, w + v.w}; + return {this->x + other.x, this->y + other.y, this->z + other.z, w + other.w}; } [[nodiscard]] - constexpr Vector4 operator-(const Vector4& v) const noexcept + constexpr Vector4 operator-(const Vector4& other) const noexcept { - return {this->x - v.x, this->y - v.y, this->z - v.z, w - v.w}; + return {this->x - other.x, this->y - other.y, this->z - other.z, w - other.w}; } [[nodiscard]] - constexpr Vector4 operator*(const Type& scalar) const noexcept + constexpr Vector4 operator*(const Type& value) const noexcept { - return {this->x * scalar, this->y * scalar, this->z * scalar, w * scalar}; + return {this->x * value, this->y * value, this->z * value, w * value}; } [[nodiscard]] - constexpr Vector4 operator*(const Vector4& v) const noexcept + constexpr Vector4 operator*(const Vector4& other) const noexcept { - return {this->x * v.x, this->y * v.y, this->z * v.z, w * v.w}; + return {this->x * other.x, this->y * other.y, this->z * other.z, w * other.w}; } [[nodiscard]] - constexpr Vector4 operator/(const Type& scalar) const noexcept + constexpr Vector4 operator/(const Type& value) const noexcept { - return {this->x / scalar, this->y / scalar, this->z / scalar, w / scalar}; + return {this->x / value, this->y / value, this->z / value, w / value}; } [[nodiscard]] - constexpr Vector4 operator/(const Vector4& v) const noexcept + constexpr Vector4 operator/(const Vector4& other) const noexcept { - return {this->x / v.x, this->y / v.y, this->z / v.z, w / v.w}; + return {this->x / other.x, this->y / other.y, this->z / other.z, w / other.w}; } [[nodiscard]]