From ac2f94f242172081487c6ee59c2e1cdee5d685c9 Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Sun, 17 Jul 2022 03:55:40 +0200 Subject: [PATCH] maths: Add Distance function --- src/maths.c | 4 ++++ src/maths.h | 1 + 2 files changed, 5 insertions(+) diff --git a/src/maths.c b/src/maths.c index ed5964e..4430608 100644 --- a/src/maths.c +++ b/src/maths.c @@ -54,3 +54,7 @@ SYMBOL_EXPORT int Sign(double val) { SYMBOL_EXPORT double Fract(double val) { return val - floor(val); } + +SYMBOL_EXPORT double Distance(double x1, double y1, double x2, double y2) { + return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)); +} diff --git a/src/maths.h b/src/maths.h index 8c428dc..3ef7553 100644 --- a/src/maths.h +++ b/src/maths.h @@ -30,5 +30,6 @@ double Clamp(double left, double right, double val); double Lerp(double left, double right, double pos); int Sign(double val); double Fract(double val); +double Distance(double x1, double y1, double x2, double y2); #endif /* LIBSUPERDERPY_MATHS_H */