| |
Conrad
Registered: Nov 2006 Posts: 849 |
How easy is it to calculate sine tables from the bare bones in ML?
Hi!
I'd like to have a go at coding my own routine of calculating sine/cosine tables without use of the BASIC interpreters (pi, sin(), etc) and just use pure ML instead.
Can I ask, how easy (or how SMALL) is this to do? Do I need to do additional algorithms like factorial or are there KERNAL routines for that (if any)? Multiplication code is no problem as I've seen articles on those, I'm just thinking about the rest of math involved with sine calculation.
Thanx in advance. |
|
... 22 posts hidden. Click here to view all posts.... |
| |
Skate
Registered: Jul 2003 Posts: 494 |
There are some 256b intros with source code which generates sine tables. Check this one for example.
Too(C)o(M)p(L)ex
Of course try to learn it, not copy & paste it.
|
| |
Radiant
Registered: Sep 2004 Posts: 639 |
To avoid nasty multiplications you could approximate a circle using an accelerating vector. I think it was Zed Yago who suggested this solution on IRC some time ago, and it sounds good enough for me. |
| |
Conrad
Registered: Nov 2006 Posts: 849 |
Thanks everyone for your help! I have a rough idea what to do now! :)
radiantx: what's an accelerating vector? Is it related to I/O registers or is a much more complex formula? Again, I could ask Yago myself :) |
| |
WVL
Registered: Mar 2002 Posts: 902 |
Quote: Thanks everyone for your help! I have a rough idea what to do now! :)
radiantx: what's an accelerating vector? Is it related to I/O registers or is a much more complex formula? Again, I could ask Yago myself :)
I guess yago meant that you can approximate a sine with 2 parabolas, and to calculate those you only need to have an acceleration (which matches the amplitude and 'length' of the sine you want.) |
| |
Cruzer
Registered: Dec 2001 Posts: 1048 |
@Skate: Too bad it's some ugly sines that are generated that way. It's really just a couple of reverse parabolas, which is not the same as a real sine.
|
| |
Conrad
Registered: Nov 2006 Posts: 849 |
Ah, now I get ya, after looking up on parabolas ;).
Thanks again, all! .... off to code.
cruzer: that's okay, quick'n'dirty is all I need. |
| |
Shadow Account closed
Registered: Apr 2002 Posts: 355 |
Anyone have an example on how to access the BASIC routines from asm to generate a sine? Also how compact is such a routine, are we talking like 50 bytes or 500 bytes? |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Anything you come up with, plz write a small article about it and post it on codebase. Mkaytnku. |
| |
Skate
Registered: Jul 2003 Posts: 494 |
@Cruzer: So, your source code comment is the liar! ;)
Well, I like using plain basic for sinus calculations (slow but more flexible with ranges) in small sized intros and precalculated tables in bigger projects. |
| |
Cruzer
Registered: Dec 2001 Posts: 1048 |
"generate sine" - yeah, guess that's a stretch. :)
Well, sometimes these parabolic "sines" work pretty good, and other times it's obvious to see that something's wrong, especially in the middle, where it's hard to get the two parabolas to meet precisely. But this is based on 256b routines - it might be possible to tweak it better if the code doesn't have to be super small.
|
Previous - 1 | 2 | 3 | 4 - Next |