diff --git a/src/utils.c b/src/utils.c index 62e5a3b..e5167df 100644 --- a/src/utils.c +++ b/src/utils.c @@ -162,6 +162,10 @@ SYMBOL_EXPORT double Lerp(double left, double right, double pos) { return left + (right - left) * pos; } +SYMBOL_EXPORT double Sign(double val) { + return val / fabs(val); +} + /* linear filtering code written by SiegeLord */ SYMBOL_EXPORT ALLEGRO_COLOR InterpolateColor(ALLEGRO_COLOR c1, ALLEGRO_COLOR c2, float frac) { return al_map_rgba_f(c1.r + frac * (c2.r - c1.r), diff --git a/src/utils.h b/src/utils.h index b1a6611..dd96730 100644 --- a/src/utils.h +++ b/src/utils.h @@ -61,6 +61,7 @@ double VectorLength(double x, double y, double z); double Wrap(double left, double right, double val); double Clamp(double left, double right, double val); double Lerp(double left, double right, double pos); +double Sign(double val); ALLEGRO_COLOR InterpolateColor(ALLEGRO_COLOR c1, ALLEGRO_COLOR c2, float frac); void ScaleBitmap(ALLEGRO_BITMAP* source, int width, int height);