Re: 10 Digit Sine Lookup Added to FAQ O MATIC

From: Bob Nash <BNash_at_smud.org>
Date: Wed, 23 Oct 2002 15:44:48 -0700

You're right! SINE.f is only 6 digits. I was looking at "my" old sine
lookup code (also from Charley), thinking I had cut it from sine.f .

FYI, his original code is given below (but, he seemed to like your factoring
better than his). Charley originally used the code in a turtle graphics
demo and admits he can't remember if he wrote it himself or lifted it from
and article. His latest code was transmitted to me a few days ago.

{
---------------------------------------------------------------------------
                                Charley Shattuck's Sine Table

---------------------------------------------------------------------------
}

: table create does> ( n - sin*100000000) swap cells + @ ;

table sine
00000000 , 01745241 , 03489950 , 05233596 , 06975647 ,
        08715574 , 10452846 , 12186934 , 13917310 ,
15643447 , 17364818 , 19080900 , 20791169 , 22495105 ,
        24192190 , 25881905 , 27563736 , 29237170 ,
30901699 , 32556815 , 34202014 , 35836795 , 37460659 ,
        39073113 , 40673664 , 42261826 , 43837115 ,
45399050 , 46947156 , 48480962 , 50000000 , 51503807 ,
        52991926 , 54463904 , 55919290 , 57357644 ,
58778525 , 60181502 , 61566148 , 62932039 , 64278761 ,
        65605903 , 66913061 , 68199836 , 69465637 ,
70710678 , 71933980 , 73135370 , 74314483 , 75470958 ,
        76604444 , 77714596 , 78801075 , 79863551 ,
80901699 , 81915204 , 82903757 , 83867057 , 84804810 ,
        85716730 , 86602540 , 87461971 , 88294759 ,
89100652 , 89879405 , 90630779 , 91354546 , 92050485 ,
        92718385 , 93358043 , 93969262 , 94551858 ,
95105652 , 95630476 , 96126170 , 96592583 , 97029573 ,
        97437006 , 97814760 , 98162718 , 98480775 ,
98768834 , 99026807 , 99254615 , 99452190 , 99619470 ,
        99756405 , 99862953 , 99939083 , 99984770 ,
100000000 ,

: mirror ( n1 - n2) 180 swap - ;

: adjust ( n - positive) dup 0< if 360 + then ;

: positive ( n - sin) dup 90 > if mirror then sine ;

: negative ( n - sin) 180 - positive negate ;

: sin ( n - sin) 360 mod adjust
        dup 180 < if positive else negative then ;

: cos ( n - cos) 90 + sin ;

100000000 VALUE xscale \ use equal scaling for now, adj. in xClient,
yClient
100000000 VALUE yscale

: sin* ( n angle - sin*n)
        sin yscale */mod yscale rot 2* < 1 and + ;

: cos* ( n angle - cos*n)
        cos xscale */mod xscale rot 2* < 1 and + ;

-----Original Message-----
From: Rick VanNorman [mailto:rvn_at_forth.com]
Sent: Wednesday, October 23, 2002 2:44 PM
To: Bob Nash
Subject: [sftalk] Re: 10 Digit Sine Lookup Added to FAQ O MATIC

Ok Bob, where'd you learn to count?

   939693 , 945519 , 951057 , 956305 , 961262 ,

looks like 6 digits to me!

Wednesday, October 23, 2002, 2:36:52 PM, you wrote:

BN> I have just added a 10 digit scaled sine lookup from Charley Shattuck
(with
BN> his permission) to the FAQ O MATIC. The link is given below. Although
none
BN> of the code (except the "test3" definition) is mine, I did test it on an
BN> application that exercises all values. Note that RVN's sine.f in the
BN> library is very good (and almost identical), but provides "only" 8
digits.

----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe sftalk" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/sftalk -- check them out!
Search the archives! Visit http://www.forth.com/search for details.
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe sftalk" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/sftalk -- check them out!
Search the archives! Visit http://www.forth.com/search for details.
Received on Wed Oct 23 2002 - 15:44:23 PDT


Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!

This archive was generated 08-Feb-2012. Archive updated nightly.