Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: "Wayne K. Werner" Newsgroups: scea.yaroze.programming.3d_graphics Subject: Re: How fast is fast? Date: 6 Sep 1997 03:41:05 GMT Organization: WermX Software Lines: 36 Message-ID: <01bcba76$82a3a040$b6bf43ce@wkwerner> References: <33B09E84.191E@charlie.cns.iit.edu> <5otr2k$fv51@chuka.playstation.co.uk> <33BFCA2D.1C4F@charlie.cns.iit.edu> NNTP-Posting-Host: port82.con2.com X-Newsreader: Microsoft Internet News 4.70.1161 Ed Federmeyer wrote: > /* Don't try this at home, kids!!! :-) */ > for ( angle=0 ; angle<360 ; angle++ ) { > sin_table[i] = sin( (angle * PI) / 180 ); > cos_table[i] = cos( (angle * PI) / 180 ); ^ shouldn't this be angle? > } > This might work quite a bit faster (eliminating the fp * and especially the /): // assuming sin_table and cos_table are global void make_trig_tables(void){ float angle = 0; int degree; for(degree = 0; degree < 360; degree++){ sin_table[degree] = sin(angle); cos_table[degree] = cos(angle); angle += (PI / 180); } } Since PI and 180 are constants, (PI / 180) is evaluated at compile time. The mult and divide have been replaced with a simple add. It doesn't address the real bottleneck, of course, the trig calcs. If you try it, please let me know how the results compare with your original calc! -- Wayne K. Werner wkwerner@con2.com