2022-06-12 10:44:32 +08:00
|
|
|
|
#include "PikaMath_Math.h"
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
#define PI (3.141592653589793115997963468544185161590576171875l)
|
|
|
|
|
#define E (2.718281828459045090795598298427648842334747314453125l)
|
|
|
|
|
//初始化,填入π和e的值
|
|
|
|
|
void PikaMath_Math___init__(PikaObj *self)
|
|
|
|
|
{
|
|
|
|
|
obj_setFloat(self, "pi", PI);
|
|
|
|
|
obj_setFloat(self, "e", PI);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_acos(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return acos(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_asin(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return asin(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_atan(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return atan(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_atan2(PikaObj *self, double x, double y)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return atan2(x,y);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
int PikaMath_Math_ceil(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return ceil(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_cos(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return cos(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_cosh(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return cosh(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_degrees(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return x*180.0/PI;
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_exp(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return exp(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_fabs(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return fabs(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
int PikaMath_Math_floor(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return floor(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_fmod(PikaObj *self, double x, double y)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return fmod(x,y);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_log(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return log(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_log10(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return log10(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_log2(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return log2(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_pow(PikaObj *self, double x, double y)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return pow(x,y);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_radians(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return x*PI/180.0;
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_remainder(PikaObj *self, double x, double y)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return remainder(x,y);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_sin(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return sin(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_sinh(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return sinh(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_sqrt(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return sqrt(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_tan(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return tan(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_tanh(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return tanh(x);
|
|
|
|
|
}
|
2022-06-13 10:02:59 +00:00
|
|
|
|
double PikaMath_Math_trunc(PikaObj *self, double x)
|
2022-06-12 10:44:32 +08:00
|
|
|
|
{
|
|
|
|
|
return trunc(x);
|
|
|
|
|
}
|