|
-
Jun 22nd, 2000, 04:01 AM
#1
Thread Starter
New Member
Isn't there a faster way to calculate sine/cosine?
After I included about 60 sine/cosine functions per frame my framerate went down by about 1000(!)%
-
Jun 22nd, 2000, 05:26 AM
#2
transcendental analytic
It's because they use your math processor. You need to setup a trignonometry table by declaring arrays and store the trig functions results in them. Then use these arrays instead of vb's trignonometry functions.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 22nd, 2000, 07:46 AM
#3
Lively Member
Wouldn't this limit presision depending on how far the function is caried out in the array... if he wants to stay acurate to say 5 or 6 decimal places the vbTrig functions might be the most practical way. ( I think... but I have been wrong in the past)
-
Jun 22nd, 2000, 08:03 AM
#4
transcendental analytic
If you don't have memory problems you can make your table as huge as you want, it depends on what you're doing, you said your having frame rates, i guess youre working on a 3d-engine, i had the same problem solved it this way.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 22nd, 2000, 08:12 AM
#5
Fanatic Member
I remember once writing a program to rotate a 3d matrixed box. I just threw in a heap of constants because they compile to just their values.
A better way would be to calculate a whole heap of trigs on form load and write them to an array, then just call them.
Instead of X=Cos(45) (the function)
you have X = MyCos(45) (the array)
where the index was written with the cos of that number
It also means you can work directly in degrees and not radians.
Dim MyCos(360) as single
I = 45
MyCos(I) = COS(I) '(*180/pi) or whatever it is to convert from radians.
so MyCos(i) = 0.70711
Sorry for the math, it's early and I can't be bothered working it out exaclty, you get the idea
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
Jun 22nd, 2000, 10:01 PM
#6
Thread Starter
New Member
The (co)sine table will do fine. I think I won't need much more than 1 value/degree.
Thank you for your replies!
-Musashimaru
-
Jun 22nd, 2000, 11:30 PM
#7
Fanatic Member
Is that MusashiMaru as in the Hawaian Sumo Wrestler?
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
Jun 23rd, 2000, 02:57 AM
#8
Thread Starter
New Member
O yeah!
btw. It's only a nick. I'n not (shock!) the real Musashimaru :-)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|