mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-12 07:34:50 +00:00
Add degree variants of FLOP operations
- Added versions of the trig operations supported by FLOP that can work with degrees directly instead of radians. - Reorder FLOPs into more sensible groupings.
This commit is contained in:
parent
0468b1f9ce
commit
ff7b1f6e5e
3 changed files with 54 additions and 27 deletions
|
@ -79,21 +79,30 @@ enum
|
|||
{
|
||||
FLOP_ABS,
|
||||
FLOP_NEG,
|
||||
FLOP_ACOS,
|
||||
FLOP_ASIN,
|
||||
FLOP_ATAN,
|
||||
FLOP_COS,
|
||||
FLOP_COSH,
|
||||
FLOP_EXP,
|
||||
FLOP_LOG,
|
||||
FLOP_LOG10,
|
||||
FLOP_SIN,
|
||||
FLOP_SINH,
|
||||
FLOP_TAN,
|
||||
FLOP_TANH,
|
||||
FLOP_SQRT,
|
||||
FLOP_CEIL,
|
||||
FLOP_FLOOR,
|
||||
|
||||
FLOP_ACOS, // This group works with radians
|
||||
FLOP_ASIN,
|
||||
FLOP_ATAN,
|
||||
FLOP_COS,
|
||||
FLOP_SIN,
|
||||
FLOP_TAN,
|
||||
|
||||
FLOP_ACOS_DEG, // This group works with degrees
|
||||
FLOP_ASIN_DEG,
|
||||
FLOP_ATAN_DEG,
|
||||
FLOP_COS_DEG,
|
||||
FLOP_SIN_DEG,
|
||||
FLOP_TAN_DEG,
|
||||
|
||||
FLOP_COSH,
|
||||
FLOP_SINH,
|
||||
FLOP_TANH,
|
||||
};
|
||||
|
||||
// Cast operations
|
||||
|
|
|
@ -101,21 +101,30 @@ static const char *const FlopNames[] =
|
|||
{
|
||||
"abs",
|
||||
"neg",
|
||||
"acos",
|
||||
"asin",
|
||||
"atan",
|
||||
"cos",
|
||||
"cosh",
|
||||
"exp",
|
||||
"log",
|
||||
"log10",
|
||||
"sin",
|
||||
"sinh",
|
||||
"tan",
|
||||
"tanh",
|
||||
"sqrt",
|
||||
"ceil",
|
||||
"floor"
|
||||
"floor",
|
||||
|
||||
"acos rad",
|
||||
"asin rad",
|
||||
"atan rad",
|
||||
"cos rad",
|
||||
"sin rad",
|
||||
"tan rad",
|
||||
|
||||
"acos deg",
|
||||
"asin deg",
|
||||
"atan deg",
|
||||
"cos deg",
|
||||
"sin deg",
|
||||
"tan deg",
|
||||
|
||||
"cosh",
|
||||
"sinh",
|
||||
"tanh",
|
||||
};
|
||||
|
||||
static int print_reg(FILE *out, int col, int arg, int mode, int immshift, const VMScriptFunction *func);
|
||||
|
|
|
@ -1369,21 +1369,30 @@ static double DoFLOP(int flop, double v)
|
|||
{
|
||||
case FLOP_ABS: return fabs(v);
|
||||
case FLOP_NEG: return -v;
|
||||
case FLOP_EXP: return exp(v);
|
||||
case FLOP_LOG: return log(v);
|
||||
case FLOP_LOG10: return log10(v);
|
||||
case FLOP_SQRT: return sqrt(v);
|
||||
case FLOP_CEIL: return ceil(v);
|
||||
case FLOP_FLOOR: return floor(v);
|
||||
|
||||
case FLOP_ACOS: return acos(v);
|
||||
case FLOP_ASIN: return asin(v);
|
||||
case FLOP_ATAN: return atan(v);
|
||||
case FLOP_COS: return cos(v);
|
||||
case FLOP_COSH: return cosh(v);
|
||||
case FLOP_EXP: return exp(v);
|
||||
case FLOP_LOG: return log(v);
|
||||
case FLOP_LOG10: return log10(v);
|
||||
case FLOP_SIN: return sin(v);
|
||||
case FLOP_SINH: return sinh(v);
|
||||
case FLOP_TAN: return tan(v);
|
||||
|
||||
case FLOP_ACOS_DEG: return acos(v) * (180 / M_PI);
|
||||
case FLOP_ASIN_DEG: return asin(v) * (180 / M_PI);
|
||||
case FLOP_ATAN_DEG: return atan(v) * (180 / M_PI);
|
||||
case FLOP_COS_DEG: return cos(v * (M_PI / 180));
|
||||
case FLOP_SIN_DEG: return sin(v * (M_PI / 180));
|
||||
case FLOP_TAN_DEG: return tan(v * (M_PI / 180));
|
||||
|
||||
case FLOP_COSH: return cosh(v);
|
||||
case FLOP_SINH: return sinh(v);
|
||||
case FLOP_TANH: return tanh(v);
|
||||
case FLOP_SQRT: return sqrt(v);
|
||||
case FLOP_CEIL: return ceil(v);
|
||||
case FLOP_FLOOR: return floor(v);
|
||||
}
|
||||
assert(0);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue