added 2 methods

This commit is contained in:
2024-06-17 01:35:16 +03:00
parent d697cc517f
commit 528b8a0ca9
2 changed files with 23 additions and 0 deletions

View File

@@ -57,9 +57,13 @@ namespace uml
{
return *reinterpret_cast<type*>(this);
}
[[nodiscard]] Vector3 Cross(const Vector3 &v) const;
[[nodiscard]] static Vector3 CreateVelocity(float pitch, float yaw, float speed);
[[nodiscard]] float Sum() const;
[[nodiscard]] float Sum2D() const;
[[nodiscard]] Vector3 ViewAngleTo(const Vector3& other) const;
[[nodiscard]]
Vector3 Normalized() const;
};
}

View File

@@ -210,4 +210,23 @@ namespace uml
0.f
};
}
Vector3 Vector3::Cross(const Vector3 &v) const
{
return {
y * v.z - z * v.y,
z * v.x - x * v.z,
x * v.y - y * v.x
};
}
Vector3 Vector3::Normalized() const
{
float length = this->Length();
if (length != 0)
{
return *this / length;
}
return *this;
}
}