From d0eca160563cddf3c8121619c2186857c998996c Mon Sep 17 00:00:00 2001 From: RobinsAviary Date: Fri, 7 Nov 2025 09:43:04 -0500 Subject: [PATCH] Added Vector2DistanceAngle function --- src/raymath.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/raymath.h b/src/raymath.h index 32dfd2b0a..47e1a0c6d 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -320,6 +320,15 @@ RMAPI float Vector2Distance(Vector2 v1, Vector2 v2) return result; } +// Calculate a vector with a distance and angle +// Angle is in radians (full rotation is 2.0f * PI), starts up and goes clockwise +RMAPI Vector2 Vector2DistanceAngle(float distance, float angle) +{ + Vector2 result = { distance*cosf(-(angle - (PI*0.5f))), distance*-sinf(-(angle - (PI*0.5f))) }; + + return result; +} + // Calculate square distance between two vectors RMAPI float Vector2DistanceSqr(Vector2 v1, Vector2 v2) {