![]() |
code efficiency
I've got a little problem: as a part of the joystick program i need to use Pitagoras'es formula, which means square root/ each time iv'e tried using it I got an error, so I thought of a lookup table. the prolem is that the lookup table will b 65,000 values long.
whar will be better- using the function, the big tble, or mabe using some simple trigonometry which requires just one lookup table 90 values long? help please. also- if you could send me a picture of the three alibration colors- red, green and yellow- it'd be really wonderful for my teams- we're Israelis, and to buy a paint color we need to choose it manually- not by its colorants. thanks in advanse |
Re: code efficiency
Quote:
If the result is going to be used as an integer, you can use a much smaller lookup table. Since many inputs will yield the same output, you can actually make a table of squares and search through it (using a binary search will keep it short). |
Re: code efficiency
If you need a square root function you can use this:
Code:
int intRoot(unsigned int value) |
Re: code efficiency
hry thanks!
acualy, i've just replaced my 65,000 table with one just 520 valuse long, but it was still too much for my bot :p :p :p thanks again BTW- your code has just sved me from an nervous breakdown:))))))))))))) my team has just discovered that our arm won't rise... and I don't seem to care at all... surely it's just all these sleepless nights trying to get me...(need sleepy smiely... ) |
general question
another thing: what is better, generaly, a lookup table or just a function?
i know it's a bit too general, but still... |
| All times are GMT -5. The time now is 23:57. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi