fixed Vec3 Vec4

This commit is contained in:
2025-03-15 19:11:31 +03:00
parent 934ca0da0a
commit 169011e238
2 changed files with 17 additions and 17 deletions

View File

@@ -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<Type>::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<Type>::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<Type>::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<Type>::Sum();
}
[[nodiscard]] constexpr std::tuple<float, float, float> AsTuple() const
[[nodiscard]] constexpr std::tuple<Type, Type, Type> AsTuple() const
{
return std::make_tuple(this->x, this->y, z);
}

View File

@@ -81,7 +81,7 @@ namespace omath
return Vector3<Type>::LengthSqr() + w * w;
}
[[nodiscard]] constexpr float Dot(const Vector4& vOther) const
[[nodiscard]] constexpr Type Dot(const Vector4& vOther) const
{
return Vector3<Type>::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};
}