maths: Add Distance function

This commit is contained in:
Sebastian Krzyszkowiak 2022-07-17 03:55:40 +02:00
parent 9dd7960584
commit ac2f94f242
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
2 changed files with 5 additions and 0 deletions

View file

@ -54,3 +54,7 @@ SYMBOL_EXPORT int Sign(double val) {
SYMBOL_EXPORT double Fract(double val) { SYMBOL_EXPORT double Fract(double val) {
return val - floor(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));
}

View file

@ -30,5 +30,6 @@ double Clamp(double left, double right, double val);
double Lerp(double left, double right, double pos); double Lerp(double left, double right, double pos);
int Sign(double val); int Sign(double val);
double Fract(double val); double Fract(double val);
double Distance(double x1, double y1, double x2, double y2);
#endif /* LIBSUPERDERPY_MATHS_H */ #endif /* LIBSUPERDERPY_MATHS_H */