From b59be3003efd465181c47aeaa56ebd5bfa0bf609 Mon Sep 17 00:00:00 2001 From: i-right-i Date: Sun, 1 Mar 2020 16:14:39 -0600 Subject: [PATCH] Update raymath.h Added Vector2Rotate Function. --- src/raymath.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/raymath.h b/src/raymath.h index c2dbc61e4..80de23a3b 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -268,6 +268,14 @@ RMDEF Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount) return result; } +// Rotate Vector by float in Degrees. +RMDEF Vector2 Vector2Rotate(Vector2 v, float degs) +{ + float rads = degs*DEG2RAD + Vector2 result = {v.x * cosf(rads) - v.y * sinf(rads) , v.x * sinf(rads) + v.y * cosf(rads) }; + return result; +} + //---------------------------------------------------------------------------------- // Module Functions Definition - Vector3 math //----------------------------------------------------------------------------------