From 56748f1fd879248d71dfbab01c508196a3a7fb95 Mon Sep 17 00:00:00 2001 From: huaqo-games Date: Thu, 6 Nov 2025 11:30:33 +0100 Subject: [PATCH] feat: add rotation vector functions --- src/engineVector.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/engineVector.c b/src/engineVector.c index fd67816..38a141f 100644 --- a/src/engineVector.c +++ b/src/engineVector.c @@ -12,3 +12,16 @@ Vector2 GetRandomVector(const Rectangle bounds) { }; } +Vector2 RotationToVector2(float rotation) +{ + float rad = rotation * (PI / 180.0f); + Vector2 vec = { cosf(rad), sinf(rad) }; + return vec; +} + +float Vector2ToRotation(Vector2 vec) +{ + float rad = atan2f(vec.y, vec.x); + float deg = rad * (180.0f / PI); + return deg; +}