mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-14 07:23:26 +00:00
fixed some stuff added constexpr
This commit is contained in:
@@ -114,7 +114,10 @@ namespace omath
|
||||
return x * vOther.x + y * vOther.y;
|
||||
}
|
||||
|
||||
[[nodiscard]] float Length() const;
|
||||
[[nodiscard]] constexpr float Length() const
|
||||
{
|
||||
return std::hypot(x, y);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr float LengthSqr() const
|
||||
{
|
||||
@@ -167,7 +170,11 @@ namespace omath
|
||||
}
|
||||
|
||||
// Normalize the vector
|
||||
[[nodiscard]] Vector2 Normalized() const;
|
||||
[[nodiscard]] constexpr Vector2 Normalized() const
|
||||
{
|
||||
const float len = Length();
|
||||
return len > 0.f ? *this / len : *this;
|
||||
}
|
||||
|
||||
// Sum of elements
|
||||
[[nodiscard]] constexpr float Sum() const
|
||||
|
||||
@@ -92,8 +92,10 @@ namespace omath
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
float DistTo(const Vector3& vOther) const;
|
||||
[[nodiscard]] constexpr float DistTo(const Vector3& vOther) const
|
||||
{
|
||||
return (*this - vOther).Length();
|
||||
}
|
||||
|
||||
constexpr Vector3& Abs()
|
||||
{
|
||||
@@ -112,14 +114,21 @@ namespace omath
|
||||
{
|
||||
return Vector2::Dot(vOther) + z * vOther.z;
|
||||
}
|
||||
[[nodiscard]] float Length() const;
|
||||
|
||||
[[nodiscard]] constexpr float Length() const
|
||||
{
|
||||
return std::hypot(x, y, z);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr float LengthSqr() const
|
||||
{
|
||||
return Vector2::LengthSqr() + z * z;
|
||||
}
|
||||
|
||||
[[nodiscard]] float Length2D() const;
|
||||
[[nodiscard]] constexpr float Length2D() const
|
||||
{
|
||||
return Vector2::Length();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr Vector3 operator-() const
|
||||
{
|
||||
@@ -182,8 +191,12 @@ namespace omath
|
||||
[[nodiscard]] static Vector3 UpVector(float pitch, float yaw, float roll);
|
||||
|
||||
|
||||
[[nodiscard]]
|
||||
Vector3 Normalized() const;
|
||||
[[nodiscard]] constexpr Vector3 Normalized() const
|
||||
{
|
||||
const float length = this->Length();
|
||||
|
||||
return length != 0 ? *this / length : *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::tuple<float, float, float> AsTuple() const
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace omath::projection
|
||||
|
||||
[[nodiscard]] Mat<4, 4> GetViewMatrix() const;
|
||||
|
||||
[[nodiscard]] std::expected<Vector2, Error> WorldToScreen(Vector3 worldPosition) const;
|
||||
[[nodiscard]] std::expected<Vector3, Error> WorldToScreen(const Vector3& worldPosition) const;
|
||||
|
||||
ViewPort m_viewPort{};
|
||||
float m_fieldOfView;
|
||||
|
||||
Reference in New Issue
Block a user