From 448ca88dcde2f4fb03fb64dc04c5cc34cfe744fc Mon Sep 17 00:00:00 2001 From: DFelipehDEV Date: Mon, 17 Feb 2025 15:00:07 +0000 Subject: [PATCH 1/2] added lerp_angle --- gm82core.gej | 13 +++++++++++++ source/math.c | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/gm82core.gej b/gm82core.gej index 5d65cd6..a0273c0 100644 --- a/gm82core.gej +++ b/gm82core.gej @@ -82,6 +82,19 @@ ], "returntype": 2 }, + { + "name": "lerp_angle", + "extname": "", + "calltype": 12, + "helpline": "lerp_angle(from,to,amount)", + "hidden": false, + "argtypes": [ + 2, + 2, + 2 + ], + "returntype": 2 + }, { "name": "box_distance", "extname": "", diff --git a/source/math.c b/source/math.c index 5cd8686..bf8c391 100644 --- a/source/math.c +++ b/source/math.c @@ -197,6 +197,16 @@ GMREAL approach_angle(double ang1, double ang2, double step) { return fmod(360.0-fmod(360.0-(ang1+max(-step,d)),360.0),360.0); } +GMREAL lerp_angle(double from, double to, double amount) { + //from: start angle + //to: destination angle + //amount: amount of interpolation. + //returns: interpolated angle + //Linearly interpolates between two angles (in radians). + + return from + angle_difference(from, to) * amount; +} + GMREAL darccos(double ang) { ///darccos(ang) //ang: angle in degrees From 531655960cb391a02163dbb45f6d172d68994613 Mon Sep 17 00:00:00 2001 From: DFelipehDEV Date: Mon, 17 Feb 2025 15:03:51 +0000 Subject: [PATCH 2/2] *in degrees --- source/math.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/math.c b/source/math.c index bf8c391..922732c 100644 --- a/source/math.c +++ b/source/math.c @@ -202,7 +202,7 @@ GMREAL lerp_angle(double from, double to, double amount) { //to: destination angle //amount: amount of interpolation. //returns: interpolated angle - //Linearly interpolates between two angles (in radians). + //Linearly interpolates between two angles (in degrees). return from + angle_difference(from, to) * amount; }