Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Trig calculations vs. lookup tables
Index -> General Programming
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
do_pete




PostPosted: Fri Sep 15, 2006 9:30 am   Post subject: Trig calculations vs. lookup tables

I'm planning on making a game in Python that includes lots of trigonometry. Should I invest in making lookup tables to increase the speed or would that not make a difference?
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Fri Sep 15, 2006 2:20 pm   Post subject: (No subject)

I'm sure it would make at least a bit of a difference, though it really matters on how important speed and smooth execution will be in your game. In any case, I don't see why you shouldn't use them..
Cervantes




PostPosted: Fri Sep 15, 2006 2:44 pm   Post subject: (No subject)

[Gandalf] wrote:
In any case, I don't see why you shouldn't use them..

Because they use up memory. If you're already using lots, you should be careful about its use. If you want to be precise in the values you get, you'll have to use lots of memory to store that accuracy.
bugzpodder




PostPosted: Fri Sep 15, 2006 5:47 pm   Post subject: (No subject)

if you are worried about speed, then you shouldnt be using python.
[Gandalf]




PostPosted: Fri Sep 15, 2006 6:01 pm   Post subject: (No subject)

Cervantes, true that. Though really, in most cases 1 degree accuracy won't take up a huge amount of memory and still does the job.

About speed... As far as I know Python seems like one of the better choices with regards to speed while still being beginner friendly.
Ignoring O'Caml, that is. ;)
zylum




PostPosted: Fri Sep 15, 2006 6:46 pm   Post subject: (No subject)

isnt java faster than python? either way, unless you are doing thousands of trig calculations per loop, it shouldnt slow down your program too much. do some benchmarks.
bugzpodder




PostPosted: Sat Sep 16, 2006 1:12 pm   Post subject: (No subject)

python is an interpreted language. C/C++ is compiled into bytecode. Java sort of sits in a middle but its VM are optimized enough so that you won't see too much of a performance loss compared to C/C++ (although it is still present). You may want to try out IronPython on the other hand since it works the same way as all other .net languages by compiling to IL.
wtd




PostPosted: Sat Sep 16, 2006 1:16 pm   Post subject: (No subject)

C and C++ (and many other languages) are compiled into native machine code.

Java and Python are compiled to bytecode which is interpreted. Or alternatively, the interpreting environment may Just-in-Time compile this bytecode to native machine code.
Sponsor
Sponsor
Sponsor
sponsor
bugzpodder




PostPosted: Sat Sep 16, 2006 5:50 pm   Post subject: (No subject)

right, thats what i meant Very Happy
do_pete




PostPosted: Tue Sep 19, 2006 9:33 am   Post subject: (No subject)

Okay, thanks for the help. If I need more speed for my program is it possible to integrate C/C++ programs into it?
zylum




PostPosted: Tue Sep 19, 2006 10:44 pm   Post subject: (No subject)

what exactly are you making that needs to that fast?
bugzpodder




PostPosted: Wed Sep 20, 2006 6:57 am   Post subject: (No subject)

Sure, use IronPython
do_pete




PostPosted: Wed Sep 20, 2006 8:35 am   Post subject: (No subject)

zylum wrote:
what exactly are you making that needs to that fast?
I'm planning on making a 2d version of Battlefield 2.
bugzpodder




PostPosted: Wed Sep 20, 2006 9:14 am   Post subject: (No subject)

or look into python C API. although its more for C++ programmers to have access to python, rather than other way around
wtd




PostPosted: Wed Sep 20, 2006 10:45 am   Post subject: (No subject)

I would mention that Ruby is considered to have one of the simplest C interfaces available. With it you can wrap C code so that it can be called from Ruby just as you would call any other Ruby code.
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 26 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: