A month or so ago, I uploaded Spirograph CE, which, understandably, generated relatively few downloads due to the fact that it was written in pure TI-BASIC. I was a little disappointed, as I had spent much time on this file (The algorithms I used were ninja, by the way), but I'm setting out to write this file anew in ICE. It'll be tailored specifically for Spirograph drawing, so speed will be dramatically increased without the need to query dozens of variables for each point drawn. It will include much more functionality than its predecessor, and will be built to be both heavily customizeable and friendly to the non math whiz at the same time. Here are the features of both programs:

Spirograph CE (TI-BASIC)
1) Spirograph drawing confined to graph screen
2) Very slow drawing speed
3) Intelligent Tmax and Tstep variable
4) Same Tmax and Tstep had to be shared by all graphs on one screen
5) Relatively complex data entry
6) Three colors and graphs at once, maximum
7) 10 slots of image storage

Spirograph CE (ICE)
1) Spirograph drawing at full screen
2) Nearly instant graph drawing
3) Gear visualization while customizing gear data
4) Independent Tmax and Tstep vars for each graph, allowing for very precise drawing
5) Extremely complex data entry is available, including non-circular shapes
6) 256 colors and graphs available
7) 256 slots of GDB-like storage (images recalled will include graph data)
8) Outputs instructions for creating the same Spirograph with the original Spirograph graphing toy

My only roadblock as of right now is the lack of trigonometry functions within ICE. I could put trig tables into lists, which I will probably end up doing, but complications will arise due to ICE's and the calculator's parameters. A sin( and a cos( would be much more easy to handle. If anyone can construct hex codes for these commands, they would be appreciated very much. Put any suggestions below.

EDIT:
Another thing I've been experimenting with is a 3D Paremetric Function engine for this program. I wouldn't worry about graph rotation quite yet, but one-screen 3D (you cannot rotate the view) is wuite doable.
Trig functions would indeed be the main struggle, and I'm not sure yet how to solve that. I might search online for an ez80 routine that calculates the sin/cos/tan of an expression.
The only way I can think is to 1. Write Floating point Routines, and 2. Taylor Series (look it up)
The following quote is from the eZ80 Optimized Routines topic:
Hactar wrote:
While working on my 3D renderer I wrote some simple LUT-based trigonometry routines. It takes input in register A where 256 = 360°. The result is in 16.8 fixed-point, though you could just change the lookup table to return any other format. Here you go:

EDIT: I think it's pretty well optimized, but I wouldn't say it's perfect. I don't really like needing to use B to store the top two bits of A...


Code:
; Destroys A B DE
; Result in HL
CosA:
   add a,64
SinA:
   ld b,a
   and a,%00111111
   ld hl,3 \ ld h,a \ mlt hl
   bit 6,b
   jr z,_
   ex de,hl
   ld hl,63*3
   sbc hl,de
_:   ld de,SinCosLUT
   add hl,de
   bit 7,b
   jr z,_
   ld de,(hl)
   or a,a \ sbc hl,hl ; carry could have been set by ADD HL,DE four lines earlier
   sbc hl,de
   ret
_:   ld hl,(hl) \ ret

SinCosLUT: ; 192 bytes (64 items, 3 bytes each)
; This could probably be made to be 2 bytes per item, but it would be harder to clear out the MSByte of the output
   .dl 0
   .dl 6
   .dl 13
   .dl 19
   .dl 25
   .dl 31
   .dl 38
   .dl 44
   .dl 50
   .dl 56
   .dl 62
   .dl 68
   .dl 74
   .dl 80
   .dl 86
   .dl 92
   .dl 98
   .dl 104
   .dl 109
   .dl 115
   .dl 121
   .dl 126
   .dl 132
   .dl 137
   .dl 142
   .dl 147
   .dl 152
   .dl 157
   .dl 162
   .dl 167
   .dl 172
   .dl 177
   .dl 181
   .dl 185
   .dl 190
   .dl 194
   .dl 198
   .dl 202
   .dl 206
   .dl 209
   .dl 213
   .dl 216
   .dl 220
   .dl 223
   .dl 226
   .dl 229
   .dl 231
   .dl 234
   .dl 237
   .dl 239
   .dl 241
   .dl 243
   .dl 245
   .dl 247
   .dl 248
   .dl 250
   .dl 251
   .dl 252
   .dl 253
   .dl 254
   .dl 255
   .dl 255
   .dl 256
   .dl 256

I'm terrible at assembly, so I don't know what any of this means Razz but I found this. Could this be of any help?[/url]
I would like to add that the basic version is fine, and you could use more slots by doing

Code:
{espression1,expression2,...,expression999

and put that into the [y=] functions. If you are using parametric insert that into each function, giving you a lot more spaces for spirographs.

I love the original program, but with ASM, it can only get better!
I've decided on brute-forcing trig tables into lists for now... It'll need to be very precise, so I'm not sure if there's enough room in the lists. If I find a better way that works, I'll implement it immediately.

GUI is nearly complete, but little number crunching has been put in place yet.
You might be able to get some ideas for fast, accurate sine and cosine without the actual transcendental functions from articles like this one:
http://lab.polygonal.de/2007/07/18/fast-and-accurate-sinecosine-approximation/

Edit: For those like Nik looking for the DevMaster explanation of the approximations:
http://web.archive.org/web/20060619143657/http://www.devmaster.net/forums/showthread.php?t=5784
KermMartian wrote:
You might be able to get some ideas for fast, accurate sine and cosine without the actual transcendental functions from articles like this one:
http://lab.polygonal.de/2007/07/18/fast-and-accurate-sinecosine-approximation/

Edit: For those like Nik looking for the DevMaster explanation of the approximations:
http://web.archive.org/web/20060619143657/http://www.devmaster.net/forums/showthread.php?t=5784
Thanks Kerm! This will be ver helpful, unless I ever need trig in Degrees. Otherwise, I will certainly use this in my program.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement