Skip to content

Commit

Permalink
[Core] [Math] Fix fposmod() function
Browse files Browse the repository at this point in the history
ffff


meth
  • Loading branch information
aaronfranke committed Jun 10, 2018
1 parent acd9646 commit eebe41b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions core/math/math_funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,22 @@ class Math {
static _ALWAYS_INLINE_ float abs(float g) { return absf(g); }
static _ALWAYS_INLINE_ int abs(int g) { return g > 0 ? g : -g; }

static _ALWAYS_INLINE_ double fposmod(double p_x, double p_y) { return (p_x >= 0) ? Math::fmod(p_x, p_y) : p_y - Math::fmod(-p_x, p_y); }
static _ALWAYS_INLINE_ float fposmod(float p_x, float p_y) { return (p_x >= 0) ? Math::fmod(p_x, p_y) : p_y - Math::fmod(-p_x, p_y); }
static _ALWAYS_INLINE_ double fposmod(double p_x, double p_y) {
double value = Math::fmod(p_x, p_y);
if ((value < 0 && p_y > 0) || (value > 0 && p_y < 0)) {
value += p_y;
}
value += 0.0;
return value;
}
static _ALWAYS_INLINE_ float fposmod(float p_x, float p_y) {
float value = Math::fmod(p_x, p_y);
if ((value < 0 && p_y > 0) || (value > 0 && p_y < 0)) {
value += p_y;
}
value += 0.0;
return value;
}

static _ALWAYS_INLINE_ double deg2rad(double p_y) { return p_y * Math_PI / 180.0; }
static _ALWAYS_INLINE_ float deg2rad(float p_y) { return p_y * Math_PI / 180.0; }
Expand Down

0 comments on commit eebe41b

Please sign in to comment.