From fd97fd1748ab1d7499db773491835863a684f889 Mon Sep 17 00:00:00 2001 From: Victor Gallet Date: Mon, 22 Jan 2024 20:36:18 +0100 Subject: [PATCH] Add Vector2Dir function to get the direction vector of two given points --- src/raymath.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/raymath.h b/src/raymath.h index b46243f4e..788ab1c5f 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -253,6 +253,14 @@ RMAPI Vector2 Vector2Add(Vector2 v1, Vector2 v2) return result; } +// Get direction vector of two points +RMAPI Vector2 Vector2Dir(Vector2 p1, Vector2 p2) +{ + Vector2 result = { p2.x - p1.x, p2.y - p1.y }; + + return result; +} + // Add vector and float value RMAPI Vector2 Vector2AddValue(Vector2 v, float add) {