My goal is to be able to check at least once every 8 pixels of space from the center of the screen to radius 'size'.
so far I've gotten this:
int multi=8;
int max=360*size/multi;
i=0;
while(i<max){
i+=max*2/(max-i);
x = multi * sin(i) * (max-i /360) /65535;
y = multi * cos(i) * (max-i /360) /65535;
setPixel(x+(imageWidth(screen)/2),y+(imageHeight(screen)/2),rgb(255,255,255),screen);
}
This works perfectly. The problem is, I need to have the system start from the center and spiral outwards whereas right now it's going from the outside in. The obvious solution, to me, would be:
int multi=8;
int max=360*size/multi;
i=max;
while(i>0){
i-=max*2/(max-i);
x = multi * sin(i) * (max-i /360) /65535;
y = multi * cos(i) * (max-i /360) /65535;
setPixel(x+(imageWidth(screen)/2),y+(imageHeight(screen)/2),rgb(255,255,255),screen);
}
I just set 'i' to max and told 'i' to subtract rather than add. Buuuut this doesn't work.
By doing a log of the first version and seeing what 'i' finished on, I got 9097. If I set i to 9097 instead of max, it works perfectly. I need to be able to change the 'size' variable though so this isnt going to be a good option.
I need to know the equation for what to set 'i' to.
Can anyone help?
EDIT: I should also add that when I do set it to 9097, and set wth while condition to i>0, it will never finish because i increases regardless of it being subtracted from. so there's really two things I need: the condition and the initial set.