diff --git a/include/uml/Vector3.h b/include/uml/Vector3.h index 1fee6da..4b6cc09 100644 --- a/include/uml/Vector3.h +++ b/include/uml/Vector3.h @@ -47,7 +47,7 @@ namespace uml Vector3 operator*(const Vector3& v) const; Vector3 operator/(float fl) const; Vector3 operator/(const Vector3& v) const; - [[nodiscard]] Vector3 Transform(const Vector3& angles, float length) const; + [[nodiscard]] static Vector3 CreateVelocity(const Vector3& angles, const float length) ; [[nodiscard]] float Sum() const; [[nodiscard]] float Sum2D() const; [[nodiscard]] Vector3 ViewAngleTo(const Vector3& other) const; diff --git a/source/Vector3.cpp b/source/Vector3.cpp index ddeb56f..45715dc 100644 --- a/source/Vector3.cpp +++ b/source/Vector3.cpp @@ -178,14 +178,14 @@ namespace uml return {x / v.x, y / v.y, z / v.z}; } - Vector3 Vector3::Transform(const Vector3 &angles, const float length) const + Vector3 Vector3::CreateVelocity(const Vector3 &angles, const float length) { - Vector3 transformed; - transformed.x += cosf(angles.y * static_cast(M_PI / 180.f)) * length; - transformed.y += sinf(angles.y * static_cast(M_PI / 180.f)) * length; - transformed.z += tanf(angles.x * static_cast(M_PI / 180.f)) * length; - - return transformed; + return + { + std::cos(angles::DegToRad(angles.y)) * length, + std::sin(angles::DegToRad(angles.y)) * length, + std::tan(angles::DegToRad(angles.x)) * length, + }; } float Vector3::Sum() const