let's complete the math func support in embryo (trivial add) and
document it in changelog, and news to justify 1.2 :) SVN revision: 70204
This commit is contained in:
parent
39f466dcfd
commit
1cec0b6ee3
|
@ -27,3 +27,8 @@
|
|||
|
||||
* Fix windows compilation issues
|
||||
|
||||
2012-04-16 Carsten Haitzler (The Rasterman)
|
||||
|
||||
* Add asin(), acos(), atan(), atan2(), log1p(), cbrt(), exp(),
|
||||
exp2(), hypot(), EMBRYO_12 define
|
||||
|
||||
|
|
|
@ -1,5 +1,30 @@
|
|||
Embryo 1.1.0
|
||||
Embryo 1.2.0
|
||||
|
||||
Changes since Embryo 1.1.0:
|
||||
---------------------------
|
||||
|
||||
Additions:
|
||||
|
||||
* exotic support
|
||||
* asin()
|
||||
* acos()
|
||||
* atan()
|
||||
* atan2()
|
||||
* log1p()
|
||||
* cbrt()
|
||||
* exp(),
|
||||
* exp2()
|
||||
* hypot()
|
||||
* EMBRYO_12
|
||||
|
||||
Fixes:
|
||||
|
||||
* windows compilation support
|
||||
|
||||
Improvements:
|
||||
|
||||
* exotic support
|
||||
|
||||
Changes since Embryo 1.0.0:
|
||||
---------------------------
|
||||
|
||||
|
@ -11,3 +36,4 @@ Fixes:
|
|||
Improvements:
|
||||
|
||||
* make embryo_cc use eina_prefix to determine installation location
|
||||
|
||||
|
|
|
@ -211,3 +211,21 @@ stock bool:operator!(Float:oper)
|
|||
forward operator%(Float:oper1, Float:oper2);
|
||||
forward operator%(Float:oper1, oper2);
|
||||
forward operator%(oper1, Float:oper2);
|
||||
|
||||
/**************************************************************************/
|
||||
/* ADDED in embryo 1.2 */
|
||||
/**************************************************************************/
|
||||
/* use this to determine embryo age */
|
||||
#define EMBRYO_12 12
|
||||
/* Return the inverse sine, cosine or tangent. The output may be radians, */
|
||||
/* degrees or grades. */
|
||||
native Float:asin(Float:value, Float_Angle_Mode:mode=RADIAN);
|
||||
native Float:acos(Float:value, Float_Angle_Mode:mode=RADIAN);
|
||||
native Float:atan(Float:value, Float_Angle_Mode:mode=RADIAN);
|
||||
native Float:atan2(Float:valuey, Float:valuex, Float_Angle_Mode:mode=RADIAN);
|
||||
/* same as libc functions */
|
||||
native Float:log1p(Float:value);
|
||||
native Float:cbrt(Float:value);
|
||||
native Float:exp(Float:value);
|
||||
native Float:exp2(Float:value);
|
||||
native Float:hypot(Float:valuex, Float:valuey);
|
||||
|
|
|
@ -249,6 +249,7 @@ _embryo_fp_log(Embryo_Program *ep, Embryo_Cell *params)
|
|||
return 0;
|
||||
}
|
||||
if (ff == 10.0) f = log10f(f);
|
||||
else if (ff == 2.0) f = log2f(f);
|
||||
else f = (logf(f) / logf(ff));
|
||||
return EMBRYO_FLOAT_TO_CELL(f);
|
||||
}
|
||||
|
@ -307,6 +308,125 @@ _embryo_fp_abs(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
|
|||
return EMBRYO_FLOAT_TO_CELL(f);
|
||||
}
|
||||
|
||||
static Embryo_Cell
|
||||
_embryo_fp_asin(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
|
||||
{
|
||||
/* params[1] = float operand 1 (angle) */
|
||||
/* params[2] = float operand 2 (radix) */
|
||||
float f;
|
||||
|
||||
if (params[0] != (2 * sizeof(Embryo_Cell))) return 0;
|
||||
f = EMBRYO_CELL_TO_FLOAT(params[1]);
|
||||
f = sinf(f);
|
||||
f = _embryo_fp_degrees_to_radians(f, params[2]);
|
||||
return EMBRYO_FLOAT_TO_CELL(f);
|
||||
}
|
||||
|
||||
static Embryo_Cell
|
||||
_embryo_fp_acos(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
|
||||
{
|
||||
/* params[1] = float operand 1 (angle) */
|
||||
/* params[2] = float operand 2 (radix) */
|
||||
float f;
|
||||
|
||||
if (params[0] != (2 * sizeof(Embryo_Cell))) return 0;
|
||||
f = EMBRYO_CELL_TO_FLOAT(params[1]);
|
||||
f = cosf(f);
|
||||
f = _embryo_fp_degrees_to_radians(f, params[2]);
|
||||
return EMBRYO_FLOAT_TO_CELL(f);
|
||||
}
|
||||
|
||||
static Embryo_Cell
|
||||
_embryo_fp_atan(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
|
||||
{
|
||||
/* params[1] = float operand 1 (angle) */
|
||||
/* params[2] = float operand 2 (radix) */
|
||||
float f;
|
||||
|
||||
if (params[0] != (2 * sizeof(Embryo_Cell))) return 0;
|
||||
f = EMBRYO_CELL_TO_FLOAT(params[1]);
|
||||
f = tanf(f);
|
||||
f = _embryo_fp_degrees_to_radians(f, params[2]);
|
||||
return EMBRYO_FLOAT_TO_CELL(f);
|
||||
}
|
||||
|
||||
static Embryo_Cell
|
||||
_embryo_fp_atan2(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
|
||||
{
|
||||
/* params[1] = float operand 1 (y) */
|
||||
/* params[2] = float operand 2 (x) */
|
||||
/* params[3] = float operand 3 (radix) */
|
||||
float f, ff;
|
||||
|
||||
if (params[0] != (3 * sizeof(Embryo_Cell))) return 0;
|
||||
f = EMBRYO_CELL_TO_FLOAT(params[1]);
|
||||
ff = EMBRYO_CELL_TO_FLOAT(params[2]);
|
||||
f = atan2f(f, ff);
|
||||
f = _embryo_fp_degrees_to_radians(f, params[3]);
|
||||
return EMBRYO_FLOAT_TO_CELL(f);
|
||||
}
|
||||
|
||||
static Embryo_Cell
|
||||
_embryo_fp_log1p(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
|
||||
{
|
||||
/* params[1] = float operand */
|
||||
float f;
|
||||
|
||||
if (params[0] != (1 * sizeof(Embryo_Cell))) return 0;
|
||||
f = EMBRYO_CELL_TO_FLOAT(params[1]);
|
||||
f = log1pf(f);
|
||||
return EMBRYO_FLOAT_TO_CELL(f);
|
||||
}
|
||||
|
||||
static Embryo_Cell
|
||||
_embryo_fp_cbrt(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
|
||||
{
|
||||
/* params[1] = float operand */
|
||||
float f;
|
||||
|
||||
if (params[0] != (1 * sizeof(Embryo_Cell))) return 0;
|
||||
f = EMBRYO_CELL_TO_FLOAT(params[1]);
|
||||
f = cbrtf(f);
|
||||
return EMBRYO_FLOAT_TO_CELL(f);
|
||||
}
|
||||
|
||||
static Embryo_Cell
|
||||
_embryo_fp_exp(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
|
||||
{
|
||||
/* params[1] = float operand */
|
||||
float f;
|
||||
|
||||
if (params[0] != (1 * sizeof(Embryo_Cell))) return 0;
|
||||
f = EMBRYO_CELL_TO_FLOAT(params[1]);
|
||||
f = expf(f);
|
||||
return EMBRYO_FLOAT_TO_CELL(f);
|
||||
}
|
||||
|
||||
static Embryo_Cell
|
||||
_embryo_fp_exp2(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
|
||||
{
|
||||
/* params[1] = float operand */
|
||||
float f;
|
||||
|
||||
if (params[0] != (1 * sizeof(Embryo_Cell))) return 0;
|
||||
f = EMBRYO_CELL_TO_FLOAT(params[1]);
|
||||
f = exp2f(f);
|
||||
return EMBRYO_FLOAT_TO_CELL(f);
|
||||
}
|
||||
|
||||
static Embryo_Cell
|
||||
_embryo_fp_hypot(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
|
||||
{
|
||||
/* params[1] = float operand */
|
||||
float f, ff;
|
||||
|
||||
if (params[0] != (2 * sizeof(Embryo_Cell))) return 0;
|
||||
f = EMBRYO_CELL_TO_FLOAT(params[1]);
|
||||
ff = EMBRYO_CELL_TO_FLOAT(params[2]);
|
||||
f = hypotf(f, ff);
|
||||
return EMBRYO_FLOAT_TO_CELL(f);
|
||||
}
|
||||
|
||||
/* functions used by the rest of embryo */
|
||||
|
||||
void
|
||||
|
@ -328,4 +448,14 @@ _embryo_fp_init(Embryo_Program *ep)
|
|||
embryo_program_native_call_add(ep, "cos", _embryo_fp_cos);
|
||||
embryo_program_native_call_add(ep, "tan", _embryo_fp_tan);
|
||||
embryo_program_native_call_add(ep, "abs", _embryo_fp_abs);
|
||||
/* Added in embryo 1.2 */
|
||||
embryo_program_native_call_add(ep, "asin", _embryo_fp_asin);
|
||||
embryo_program_native_call_add(ep, "acos", _embryo_fp_acos);
|
||||
embryo_program_native_call_add(ep, "atan", _embryo_fp_atan);
|
||||
embryo_program_native_call_add(ep, "atan2", _embryo_fp_atan2);
|
||||
embryo_program_native_call_add(ep, "log1p", _embryo_fp_log1p);
|
||||
embryo_program_native_call_add(ep, "cbrt", _embryo_fp_cbrt);
|
||||
embryo_program_native_call_add(ep, "exp", _embryo_fp_exp);
|
||||
embryo_program_native_call_add(ep, "exp2", _embryo_fp_exp2);
|
||||
embryo_program_native_call_add(ep, "hypot", _embryo_fp_hypot);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue