summaryrefslogtreecommitdiff
path: root/legacy/embryo
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-04-16 05:33:13 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-04-16 05:33:13 +0000
commit1cec0b6ee3c38b57f145a36958f4e7c60e161e3a (patch)
tree3a79ec04705e0b1e2988b9170008c61c7864edf4 /legacy/embryo
parent39f466dcfde6c10b88c72d0d11ec30a5eb7737eb (diff)
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
Diffstat (limited to 'legacy/embryo')
-rw-r--r--legacy/embryo/ChangeLog5
-rw-r--r--legacy/embryo/NEWS28
-rw-r--r--legacy/embryo/include/default.inc18
-rw-r--r--legacy/embryo/src/lib/embryo_float.c130
4 files changed, 180 insertions, 1 deletions
diff --git a/legacy/embryo/ChangeLog b/legacy/embryo/ChangeLog
index 297abf1499..8572eab7b3 100644
--- a/legacy/embryo/ChangeLog
+++ b/legacy/embryo/ChangeLog
@@ -27,3 +27,8 @@
27 27
28 * Fix windows compilation issues 28 * Fix windows compilation issues
29 29
302012-04-16 Carsten Haitzler (The Rasterman)
31
32 * Add asin(), acos(), atan(), atan2(), log1p(), cbrt(), exp(),
33 exp2(), hypot(), EMBRYO_12 define
34
diff --git a/legacy/embryo/NEWS b/legacy/embryo/NEWS
index 8cc49e0c4d..a71cf679e2 100644
--- a/legacy/embryo/NEWS
+++ b/legacy/embryo/NEWS
@@ -1,5 +1,30 @@
1Embryo 1.1.0 1Embryo 1.2.0
2 2
3Changes since Embryo 1.1.0:
4---------------------------
5
6Additions:
7
8 * exotic support
9 * asin()
10 * acos()
11 * atan()
12 * atan2()
13 * log1p()
14 * cbrt()
15 * exp(),
16 * exp2()
17 * hypot()
18 * EMBRYO_12
19
20Fixes:
21
22 * windows compilation support
23
24Improvements:
25
26 * exotic support
27
3Changes since Embryo 1.0.0: 28Changes since Embryo 1.0.0:
4--------------------------- 29---------------------------
5 30
@@ -11,3 +36,4 @@ Fixes:
11Improvements: 36Improvements:
12 37
13 * make embryo_cc use eina_prefix to determine installation location 38 * make embryo_cc use eina_prefix to determine installation location
39
diff --git a/legacy/embryo/include/default.inc b/legacy/embryo/include/default.inc
index 0733503660..b82ff14b0a 100644
--- a/legacy/embryo/include/default.inc
+++ b/legacy/embryo/include/default.inc
@@ -211,3 +211,21 @@ stock bool:operator!(Float:oper)
211forward operator%(Float:oper1, Float:oper2); 211forward operator%(Float:oper1, Float:oper2);
212forward operator%(Float:oper1, oper2); 212forward operator%(Float:oper1, oper2);
213forward operator%(oper1, Float:oper2); 213forward operator%(oper1, Float:oper2);
214
215/**************************************************************************/
216/* ADDED in embryo 1.2 */
217/**************************************************************************/
218/* use this to determine embryo age */
219#define EMBRYO_12 12
220/* Return the inverse sine, cosine or tangent. The output may be radians, */
221/* degrees or grades. */
222native Float:asin(Float:value, Float_Angle_Mode:mode=RADIAN);
223native Float:acos(Float:value, Float_Angle_Mode:mode=RADIAN);
224native Float:atan(Float:value, Float_Angle_Mode:mode=RADIAN);
225native Float:atan2(Float:valuey, Float:valuex, Float_Angle_Mode:mode=RADIAN);
226/* same as libc functions */
227native Float:log1p(Float:value);
228native Float:cbrt(Float:value);
229native Float:exp(Float:value);
230native Float:exp2(Float:value);
231native Float:hypot(Float:valuex, Float:valuey);
diff --git a/legacy/embryo/src/lib/embryo_float.c b/legacy/embryo/src/lib/embryo_float.c
index 608be9da09..6efa2ae82d 100644
--- a/legacy/embryo/src/lib/embryo_float.c
+++ b/legacy/embryo/src/lib/embryo_float.c
@@ -249,6 +249,7 @@ _embryo_fp_log(Embryo_Program *ep, Embryo_Cell *params)
249 return 0; 249 return 0;
250 } 250 }
251 if (ff == 10.0) f = log10f(f); 251 if (ff == 10.0) f = log10f(f);
252 else if (ff == 2.0) f = log2f(f);
252 else f = (logf(f) / logf(ff)); 253 else f = (logf(f) / logf(ff));
253 return EMBRYO_FLOAT_TO_CELL(f); 254 return EMBRYO_FLOAT_TO_CELL(f);
254} 255}
@@ -307,6 +308,125 @@ _embryo_fp_abs(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
307 return EMBRYO_FLOAT_TO_CELL(f); 308 return EMBRYO_FLOAT_TO_CELL(f);
308} 309}
309 310
311static Embryo_Cell
312_embryo_fp_asin(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
313{
314 /* params[1] = float operand 1 (angle) */
315 /* params[2] = float operand 2 (radix) */
316 float f;
317
318 if (params[0] != (2 * sizeof(Embryo_Cell))) return 0;
319 f = EMBRYO_CELL_TO_FLOAT(params[1]);
320 f = sinf(f);
321 f = _embryo_fp_degrees_to_radians(f, params[2]);
322 return EMBRYO_FLOAT_TO_CELL(f);
323}
324
325static Embryo_Cell
326_embryo_fp_acos(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
327{
328 /* params[1] = float operand 1 (angle) */
329 /* params[2] = float operand 2 (radix) */
330 float f;
331
332 if (params[0] != (2 * sizeof(Embryo_Cell))) return 0;
333 f = EMBRYO_CELL_TO_FLOAT(params[1]);
334 f = cosf(f);
335 f = _embryo_fp_degrees_to_radians(f, params[2]);
336 return EMBRYO_FLOAT_TO_CELL(f);
337}
338
339static Embryo_Cell
340_embryo_fp_atan(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
341{
342 /* params[1] = float operand 1 (angle) */
343 /* params[2] = float operand 2 (radix) */
344 float f;
345
346 if (params[0] != (2 * sizeof(Embryo_Cell))) return 0;
347 f = EMBRYO_CELL_TO_FLOAT(params[1]);
348 f = tanf(f);
349 f = _embryo_fp_degrees_to_radians(f, params[2]);
350 return EMBRYO_FLOAT_TO_CELL(f);
351}
352
353static Embryo_Cell
354_embryo_fp_atan2(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
355{
356 /* params[1] = float operand 1 (y) */
357 /* params[2] = float operand 2 (x) */
358 /* params[3] = float operand 3 (radix) */
359 float f, ff;
360
361 if (params[0] != (3 * sizeof(Embryo_Cell))) return 0;
362 f = EMBRYO_CELL_TO_FLOAT(params[1]);
363 ff = EMBRYO_CELL_TO_FLOAT(params[2]);
364 f = atan2f(f, ff);
365 f = _embryo_fp_degrees_to_radians(f, params[3]);
366 return EMBRYO_FLOAT_TO_CELL(f);
367}
368
369static Embryo_Cell
370_embryo_fp_log1p(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
371{
372 /* params[1] = float operand */
373 float f;
374
375 if (params[0] != (1 * sizeof(Embryo_Cell))) return 0;
376 f = EMBRYO_CELL_TO_FLOAT(params[1]);
377 f = log1pf(f);
378 return EMBRYO_FLOAT_TO_CELL(f);
379}
380
381static Embryo_Cell
382_embryo_fp_cbrt(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
383{
384 /* params[1] = float operand */
385 float f;
386
387 if (params[0] != (1 * sizeof(Embryo_Cell))) return 0;
388 f = EMBRYO_CELL_TO_FLOAT(params[1]);
389 f = cbrtf(f);
390 return EMBRYO_FLOAT_TO_CELL(f);
391}
392
393static Embryo_Cell
394_embryo_fp_exp(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
395{
396 /* params[1] = float operand */
397 float f;
398
399 if (params[0] != (1 * sizeof(Embryo_Cell))) return 0;
400 f = EMBRYO_CELL_TO_FLOAT(params[1]);
401 f = expf(f);
402 return EMBRYO_FLOAT_TO_CELL(f);
403}
404
405static Embryo_Cell
406_embryo_fp_exp2(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
407{
408 /* params[1] = float operand */
409 float f;
410
411 if (params[0] != (1 * sizeof(Embryo_Cell))) return 0;
412 f = EMBRYO_CELL_TO_FLOAT(params[1]);
413 f = exp2f(f);
414 return EMBRYO_FLOAT_TO_CELL(f);
415}
416
417static Embryo_Cell
418_embryo_fp_hypot(Embryo_Program *ep __UNUSED__, Embryo_Cell *params)
419{
420 /* params[1] = float operand */
421 float f, ff;
422
423 if (params[0] != (2 * sizeof(Embryo_Cell))) return 0;
424 f = EMBRYO_CELL_TO_FLOAT(params[1]);
425 ff = EMBRYO_CELL_TO_FLOAT(params[2]);
426 f = hypotf(f, ff);
427 return EMBRYO_FLOAT_TO_CELL(f);
428}
429
310/* functions used by the rest of embryo */ 430/* functions used by the rest of embryo */
311 431
312void 432void
@@ -328,4 +448,14 @@ _embryo_fp_init(Embryo_Program *ep)
328 embryo_program_native_call_add(ep, "cos", _embryo_fp_cos); 448 embryo_program_native_call_add(ep, "cos", _embryo_fp_cos);
329 embryo_program_native_call_add(ep, "tan", _embryo_fp_tan); 449 embryo_program_native_call_add(ep, "tan", _embryo_fp_tan);
330 embryo_program_native_call_add(ep, "abs", _embryo_fp_abs); 450 embryo_program_native_call_add(ep, "abs", _embryo_fp_abs);
451 /* Added in embryo 1.2 */
452 embryo_program_native_call_add(ep, "asin", _embryo_fp_asin);
453 embryo_program_native_call_add(ep, "acos", _embryo_fp_acos);
454 embryo_program_native_call_add(ep, "atan", _embryo_fp_atan);
455 embryo_program_native_call_add(ep, "atan2", _embryo_fp_atan2);
456 embryo_program_native_call_add(ep, "log1p", _embryo_fp_log1p);
457 embryo_program_native_call_add(ep, "cbrt", _embryo_fp_cbrt);
458 embryo_program_native_call_add(ep, "exp", _embryo_fp_exp);
459 embryo_program_native_call_add(ep, "exp2", _embryo_fp_exp2);
460 embryo_program_native_call_add(ep, "hypot", _embryo_fp_hypot);
331} 461}