#include "stdlib.h"
#include "math.h"
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
gehe zum Quellcode dieser Datei
|
enum | {
FN_MUL = 0,
FN_DIV,
FN_ADD,
FN_SUB,
FN_POW,
FN_MOD,
FN_LOG,
FN_LOG2,
FN_LOG10,
FN_SQRT,
FN_NEG,
FN_DEG,
FN_RAD,
FN_EQ,
FN_LT,
FN_LE,
FN_INT,
FN_CEIL,
FN_FLOOR,
FN_ROUND,
FN_SIN,
FN_COS,
FN_TAN,
FN_ASIN,
FN_ACOS,
FN_ATAN
} |
|
enum | { ROTATE = 0,
VECTOR
} |
|
|
static double | arg (lua_State *L, int n) |
|
static double * | newval (lua_State *L, double v) |
|
static int | fmath_new (lua_State *L) |
|
static int | fmath_toStr (lua_State *L) |
|
static void | cordic (int f, double *x, double *y, double *z) |
|
static double | fmod (double x, double y) |
|
static double | cathetus (double x) |
|
static void | sincosCordic (double phi, double *sinphi, double *cosphi) |
|
static void | atanhypCordic (double x, double y, double *phi, double *hyp) |
|
static int | twoargfn (lua_State *L, int fn) |
|
static int | oneargfn (lua_State *L, int fn) |
|
static int | boolfn (lua_State *L, int fn) |
|
static int | intfn (lua_State *L, int fn) |
|
static int | trigfn (lua_State *L, int fn) |
|
static int | atrigfn (lua_State *L, int fn) |
|
static int | fmath_rec (lua_State *L) |
|
static int | fmath_pol (lua_State *L) |
|
static int | fmath_mul (lua_State *L) |
|
static int | fmath_div (lua_State *L) |
|
static int | fmath_add (lua_State *L) |
|
static int | fmath_sub (lua_State *L) |
|
static int | fmath_pow (lua_State *L) |
|
static int | fmath_mod (lua_State *L) |
|
static int | fmath_eq (lua_State *L) |
|
static int | fmath_lt (lua_State *L) |
|
static int | fmath_le (lua_State *L) |
|
static int | fmath_neg (lua_State *L) |
|
static int | fmath_log (lua_State *L) |
|
static int | fmath_log2 (lua_State *L) |
|
static int | fmath_log10 (lua_State *L) |
|
static int | fmath_sqrt (lua_State *L) |
|
static int | fmath_deg (lua_State *L) |
|
static int | fmath_rad (lua_State *L) |
|
static int | fmath_int (lua_State *L) |
|
static int | fmath_ceil (lua_State *L) |
|
static int | fmath_floor (lua_State *L) |
|
static int | fmath_round (lua_State *L) |
|
static int | fmath_sin (lua_State *L) |
|
static int | fmath_cos (lua_State *L) |
|
static int | fmath_tan (lua_State *L) |
|
static int | fmath_asin (lua_State *L) |
|
static int | fmath_acos (lua_State *L) |
|
static int | fmath_atan (lua_State *L) |
|
LUALIB_API int | luaopen_fmath (lua_State *L) |
|
#define fabs |
( |
|
x) | |
((((x) < 0.0) ? -(x) : (x))) |
#define INV_GAIN_CIRCLE 0.60725293501477 |
#define trunc |
( |
|
x) | |
((double)((int)(x))) |
Aufzählungswerte |
---|
FN_MUL |
|
FN_DIV |
|
FN_ADD |
|
FN_SUB |
|
FN_POW |
|
FN_MOD |
|
FN_LOG |
|
FN_LOG2 |
|
FN_LOG10 |
|
FN_SQRT |
|
FN_NEG |
|
FN_DEG |
|
FN_RAD |
|
FN_EQ |
|
FN_LT |
|
FN_LE |
|
FN_INT |
|
FN_CEIL |
|
FN_FLOOR |
|
FN_ROUND |
|
FN_SIN |
|
FN_COS |
|
FN_TAN |
|
FN_ASIN |
|
FN_ACOS |
|
FN_ATAN |
|
Definiert in Zeile 131 der Datei lfmathlib.c.
Aufzählungswerte |
---|
ROTATE |
|
VECTOR |
|
Definiert in Zeile 160 der Datei lfmathlib.c.
static void atanhypCordic |
( |
double |
x, |
|
|
double |
y, |
|
|
double * |
phi, |
|
|
double * |
hyp |
|
) |
| |
|
static |
Definiert in Zeile 234 der Datei lfmathlib.c.
235 if (
x == 0 &&
y == 0) {
261 case 2: z =
M_PI - z;
break;
262 case 3: z = z -
M_PI;
break;
263 case 4: z = -z;
break;
static double cathetus |
( |
double |
x) | |
|
|
static |
static void cordic |
( |
int |
f, |
|
|
double * |
x, |
|
|
double * |
y, |
|
|
double * |
z |
|
) |
| |
|
static |
Definiert in Zeile 181 der Datei lfmathlib.c.
183 double xstep, ystep, zstep = 1;
186 for (i = 0; i <
N; i += 1) {
192 }
else zstep = zstep / 2.0;
193 int f1 = (f) ? *
y >= 0 : *z < 0;
194 *
x = (f1) ? *
x + ystep : *
x - ystep;
195 *
y = (f1) ? *
y - xstep : *
y + xstep;
196 *z = (f1) ? *z + zstep : *z - zstep;
Definiert in Zeile 440 der Datei lfmathlib.c.
441 double r =
arg(L, 1);
442 double theta =
arg(L, 2);
Definiert in Zeile 99 der Datei lfmathlib.c.
102 double a =
arg(L, 1);
108 double m =
pow(10.0, p);
110 const char*
s = (a < 0) ?
"-" :
"";
112 a =
fabs(a) + (0.5 /
m);
114 unsigned int w = (int)a;
117 unsigned int d = (int)((a - w) *
m);
120 sprintf(fmt,
"%s%%u.%%0%du", s, p);
static double fmod |
( |
double |
x, |
|
|
double |
y |
|
) |
| |
|
static |
Definiert in Zeile 361 der Datei lfmathlib.c.
362 double a =
arg(L, 1);
363 double frac = a - (int)a;
370 if ((a > 0.0) && (frac != 0.0))
376 if ((a < 0.0) && (frac != 0.0))
static double* newval |
( |
lua_State * |
L, |
|
|
double |
v |
|
) |
| |
|
static |
static int oneargfn |
( |
lua_State * |
L, |
|
|
int |
fn |
|
) |
| |
|
static |
static void sincosCordic |
( |
double |
phi, |
|
|
double * |
sinphi, |
|
|
double * |
cosphi |
|
) |
| |
|
static |
Definiert in Zeile 212 der Datei lfmathlib.c.
215 int q = (int)(phi / (
M_PI / 2.0)) + 1;
217 case 2: phi =
M_PI - phi;
break;
218 case 3: phi = phi -
M_PI;
break;
219 case 4: phi = M_PI * 2.0 - phi;
break;
226 if ((q == 2) || (q == 3)) { x = -
x; }
227 if ((q == 3) || (q == 4)) { y = -
y; }
static int twoargfn |
( |
lua_State * |
L, |
|
|
int |
fn |
|
) |
| |
|
static |
Initialisierung:= {
0.78539816339745, 0.46364760900081, 0.24497866312686, 0.12435499454676,
0.06241880999596, 0.03123983343027, 0.01562372862048, 0.00781234106010,
0.00390623013197
}
Definiert in Zeile 173 der Datei lfmathlib.c.