From 169011e238e41b019b08e7ad68e7503bc1b3632d Mon Sep 17 00:00:00 2001 From: Orange Date: Sat, 15 Mar 2025 19:11:31 +0300 Subject: [PATCH] fixed Vec3 Vec4 --- include/omath/Vector3.hpp | 26 +++++++++++++------------- include/omath/Vector4.hpp | 8 ++++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/omath/Vector3.hpp b/include/omath/Vector3.hpp index af90ed6..588c608 100644 --- a/include/omath/Vector3.hpp +++ b/include/omath/Vector3.hpp @@ -110,45 +110,45 @@ namespace omath return *this; } - [[nodiscard]] constexpr float DistToSqr(const Vector3& vOther) const + [[nodiscard]] constexpr Type DistToSqr(const Vector3& vOther) const { return (*this - vOther).LengthSqr(); } - [[nodiscard]] constexpr float Dot(const Vector3& vOther) const + [[nodiscard]] constexpr Type Dot(const Vector3& vOther) const { return Vector2::Dot(vOther) + z * vOther.z; } #ifndef _MSC_VER - [[nodiscard]] constexpr float Length() const + [[nodiscard]] constexpr Type Length() const { return std::hypot(x, y, z); } - [[nodiscard]] constexpr float Length2D() const + [[nodiscard]] constexpr Type Length2D() const { return Vector2::Length(); } - [[nodiscard]] float DistTo(const Vector3& vOther) const + [[nodiscard]] Type DistTo(const Vector3& vOther) const { return (*this - vOther).Length(); } [[nodiscard]] constexpr Vector3 Normalized() const { - const float length = this->Length(); + const Type length = this->Length(); return length != 0 ? *this / length : *this; } #else - [[nodiscard]] float Length() const + [[nodiscard]] Type Length() const { return std::hypot(this->x, this->y, z); } [[nodiscard]] Vector3 Normalized() const { - const float length = this->Length(); + const Type length = this->Length(); return length != 0 ? *this / length : *this; } @@ -158,14 +158,14 @@ namespace omath return Vector2::Length(); } - [[nodiscard]] float DistTo(const Vector3& vOther) const + [[nodiscard]] Type DistTo(const Vector3& vOther) const { return (*this - vOther).Length(); } #endif - [[nodiscard]] constexpr float LengthSqr() const + [[nodiscard]] constexpr Type LengthSqr() const { return Vector2::LengthSqr() + z * z; } @@ -214,7 +214,7 @@ namespace omath this->x * v.y - this->y * v.x }; } - [[nodiscard]] constexpr float Sum() const + [[nodiscard]] constexpr Type Sum() const { return Sum2D() + z; } @@ -238,12 +238,12 @@ namespace omath return false; } - [[nodiscard]] constexpr float Sum2D() const + [[nodiscard]] constexpr Type Sum2D() const { return Vector2::Sum(); } - [[nodiscard]] constexpr std::tuple AsTuple() const + [[nodiscard]] constexpr std::tuple AsTuple() const { return std::make_tuple(this->x, this->y, z); } diff --git a/include/omath/Vector4.hpp b/include/omath/Vector4.hpp index 05530ee..f4fcadd 100644 --- a/include/omath/Vector4.hpp +++ b/include/omath/Vector4.hpp @@ -81,7 +81,7 @@ namespace omath return Vector3::LengthSqr() + w * w; } - [[nodiscard]] constexpr float Dot(const Vector4& vOther) const + [[nodiscard]] constexpr Type Dot(const Vector4& vOther) const { return Vector3::Dot(vOther) + w * vOther.w; } @@ -98,7 +98,7 @@ namespace omath return *this; } - constexpr Vector4& Clamp(const float min, const float max) + constexpr Vector4& Clamp(const Type& min, const Type& max) { this->x = std::clamp(this->x, min, max); this->y = std::clamp(this->y, min, max); @@ -126,7 +126,7 @@ namespace omath } [[nodiscard]] - constexpr Vector4 operator*(const float scalar) const + constexpr Vector4 operator*(const Type& scalar) const { return {this->x * scalar, this->y * scalar, this->z * scalar, w * scalar}; } @@ -138,7 +138,7 @@ namespace omath } [[nodiscard]] - constexpr Vector4 operator/(const float scalar) const + constexpr Vector4 operator/(const Type& scalar) const { return {this->x / scalar, this->y / scalar, this->z / scalar, w / scalar}; }