Downloads containing SEmath.asc

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Devan's Revenge (Intro)Featured Download sAlAmAnDeR Single player 9.6 Download file
TSF with JJ2+ Only: Chaos V1.1Featured Download sAlAmAnDeR Mutator 8.5 Download file

File preview

//Common math functions (v1.0 for Plus Beta Build 2013-10-19 and later) by Sir Ementaler
const float INF=1.0e+40f;
const float NaN=INF*0;
const float pi=3.1415927f;
bool isinf(float x){
  return x==INF||x==-INF;
}
bool isnan(float x){
  return x!=x;
}
bool isfinite(float x){
  return !isnan(x)&&!isinf(x);
}
int sign(int x){
  return x>0?1:x<0?-1:0;
}
float sign(float x){
  return x>0?1:x<0?-1:0;
}
float trunc(float x){
  return x>0?floor(x):ceil(x);
}
float round(float x){
  return trunc(x)+(abs(fraction(x))>=0.5?sign(x):0);
}
int min(int x,int y){
  return x<y?x:y;
}
float min(float x,float y){
  if(isnan(x)) return y;
  if(isnan(y)) return x;
  return x<y?x:y;
}
float min(int x,float y){
  return min(float(x),y);
}
float min(float x,int y){
  return min(x,float(y));
}
int max(int x,int y){
  return x>y?x:y;
}
float max(float x,float y){
  if(isnan(x)) return y;
  if(isnan(y)) return x;
  return x>y?x:y;
}
float max(int x,float y){
  return max(float(x),y);
}
float max(float x,int y){
  return max(x,float(y));
}
float cbrt(float x){
  return pow(x,1.f/3.f);
}
float exp(float x){
  return pow(2.7182818f,x);
}
float log2(float x){
  return log(x)/0.69314718f;
}
float logb(float x,float b){
  if(b==1) return NaN;
  return log(x)/log(b);
}
float asinh(float x){
  return log(x+sqrt(x*x+1));
}
float acosh(float x){
  if(x<1) return NaN;
  return log(x+sqrt(x*x-1));
}
float atanh(float x){
  if(abs(x)>1) return NaN;
  if(abs(x)==1) return sign(x)*INF;
  return log((1+x)/(1-x))/2;
}