mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
added 2 methods
This commit is contained in:
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user