(Please bare with me as I try to explain my problem to the best of my abilities)
I have a computer program that draws a sine. Each y value of the sine is stored against the x value in an array like so:
float sine[x] = y;
To find the value of my points, I iterate through each value of x from 0 to 799 using a for loop like so:
etime = 1000000;
int x;
for (x = 0; x < 800; ++x)
{
sine[x] = sin((x + etime) / 300);
}
Is there anyway I could find the value of sine[x + 1] by using the value of sine[x]?
I want to avoid computing sin((x + etime) / 300) for everypoint on the graph as it costs a lot of memory.
EDIT 1
OK so I trie implementing the solution provided but I realized that I simplified my equation too much for the results to work. This is actually how the equation is calculated:
for(k = 0; k < 799; ++k)
{
sinewave[k] = 145 * sin((0.984736 * k + etime) / 300) + 0.847563;
}
How do I calculate sinewave[k + 1] if I know sinewave[k]?
So I ended using this trig identity to replace the sin call:
sin(a+b) = sinAcosB + sinBcosA.
I was able to precompute all the values and store them in lookup tables which lowered my sin function call count from 12800 calls down to 8 calls per frame.