gaffertape / cl-osd

Automatically exported from code.google.com/p/cl-osd
0 stars 0 forks source link

Hint: Save memory, decrease cpu-load #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is not a bug, just want to give you a hint.
I used to program ICs and had a similar problem, that radian functions were to 
slow.
You can save the memory for the radians function (you said 1588 bytes) and 
speed up calculation by approaching the cosine with the first orders of its 
taylor series.
You may even be able to go without float at all.

To calculate the cosine of x you should try:
cosx = x-(x*x*x)/6+(x*x*x*x*x)/120-(x*x*x*x*x*x*x)/5040;
(only valid between -pi and pi, so convert your input first)

Depending on the availible computing power you can add one or two more orders 
to improve accuracy, but I think we do not need 0.01% accuracy for this project.

Good luck, I was waiting for someone who tries to flash the g-osd.

Original issue reported on code.google.com by RealPar...@gmail.com on 19 Aug 2011 at 9:06

GoogleCodeExporter commented 9 years ago
That's really smart! 
I didn't think of the taylor series.
Thanks for the help! I will try that.

Original comment by call...@gmail.com on 19 Aug 2011 at 9:12

GoogleCodeExporter commented 9 years ago

Original comment by call...@gmail.com on 23 Aug 2011 at 5:32