Rev 5676 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5640 | pavelyakov | 1 | //IO library |
2 | #ifndef INCLUDE_MATH_H |
||
3 | #define INCLUDE_MATH_H |
||
4 | |||
5 | #ifndef INCLUDE_KOLIBRI_H |
||
6 | #include "../lib/kolibri.h" |
||
7 | #endif |
||
8 | |||
9 | :struct MATH |
||
10 | { |
||
11 | float pi(); |
||
12 | float cos(float x); |
||
13 | float sin(float x); |
||
14 | float sqrt(float x); |
||
15 | float tan(float x); |
||
16 | float abs(float x); |
||
17 | }math; |
||
18 | :float MATH::abs(float x) |
||
19 | { |
||
20 | IF(x<0)return -x; |
||
21 | return x; |
||
22 | } |
||
23 | |||
24 | :float MATH::cos(float x) |
||
25 | { |
||
26 | float r; |
||
27 | asm |
||
28 | { |
||
29 | fld x |
||
30 | fcos |
||
31 | fstp r |
||
32 | } |
||
33 | return r; |
||
34 | } |
||
35 | :float MATH::sin(float x) |
||
36 | { |
||
37 | float r; |
||
38 | asm |
||
39 | { |
||
40 | fld x |
||
41 | fsin |
||
42 | fstp r |
||
43 | } |
||
44 | return r; |
||
45 | } |
||
46 | :float MATH::sqrt(float x) |
||
47 | { |
||
48 | float r; |
||
49 | asm |
||
50 | { |
||
51 | fld x |
||
52 | fsqrt |
||
53 | fstp r |
||
54 | } |
||
55 | return r; |
||
56 | } |
||
57 | :float MATH::tan(float x) |
||
58 | { |
||
59 | float r; |
||
60 | asm |
||
61 | { |
||
62 | fld x |
||
63 | fld1 |
||
64 | fpatan |
||
65 | fstp r |
||
66 | } |
||
67 | return r; |
||
68 | } |
||
69 | #endif0)return> |