-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsinus.txt
73 lines (68 loc) · 1.71 KB
/
sinus.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
\ *********************************************************************
\ Sinus and Cosinus
\ Filename: sinus.txt
\ Date: 10 jun 2019
\ File Version: 1.0
\ Copyright: Marc PETREMANN
\ Author: Marc PETREMANN
\ GNU General Public License
\ *********************************************************************
\ Sinus and Cosinus
\ Use table calculating integer sin.
\ Get values scaled by 10K.
decimal
-sinus
marker -sinus
: sm/rem ( d1 n1 -- n2 n3 )
2dup xor >r over >r
abs >r dabs r> um/mod
swap r> ?negate
swap r> ?negate
;
: /mod ( n1 n2 -- n3 n4 )
>r s>d r> sm/rem
;
: mod ( n1 n2 -- n3 )
/mod drop
;
flash
create sintab \ 0...90 Grad, Index in Grad
0000 , 0175 , 0349 , 0523 , 0698 ,
0872 , 1045 , 1219 , 1392 , 1564 ,
1736 , 1908 , 2079 , 2250 , 2419 ,
2588 , 2756 , 2924 , 3090 , 3256 ,
3420 , 3584 , 3746 , 3907 , 4067 ,
4226 , 4384 , 4540 , 4695 , 4848 ,
5000 , 5150 , 5299 , 5446 , 5592 ,
5736 , 5878 , 6018 , 6157 , 6293 ,
6428 , 6561 , 6691 , 6820 , 6947 ,
7071 , 7193 , 7314 , 7431 , 7547 ,
7660 , 7771 , 7880 , 7986 , 8090 ,
8192 , 8290 , 8387 , 8480 , 8572 ,
8660 , 8746 , 8829 , 8910 , 8988 ,
9063 , 9135 , 9205 , 9272 , 9336 ,
9397 , 9455 , 9511 , 9563 , 9613 ,
9659 , 9703 , 9744 , 9781 , 9816 ,
9848 , 9877 , 9903 , 9925 , 9945 ,
9962 , 9976 , 9986 , 9994 , 9998 ,
10000 ,
: sinus@ ( grad ---)
2* sintab + @ ;
: sin ( grad -- sinus )
dup 0< >r abs
360 mod
dup 180 >
if
180 - true >r
else
false >r
then
dup 90 >
if
180 swap -
then
sinus@
r> if negate then
r> if negate then ;
: cos
90 + sin ;