I'm sure some of you have used a sin or cos function to "loop" an array index back and forth through a set area. Whats troubling me is how to decide when the total amount moved equals one times something. I'll try and explain a little better....

if I have:
Code:
int movement = 0;

movement+= (int)(sin(j++ * PI / 180) * width);
....then as j increases from 0 "movement" will approach and then pass the value "width", but at which point will it match (or almost match) "width". i.e. if width = 1, at what value j will movement equal 1.
I hope that makes sense.

I could check the value continuosly using an "if" suppose - but I'd rather check values passed in are ok before the function starts than have it break half way through.

I've gotten round this before but looking back at the code I used I can't even figure out what I was doing now, no comments, slightly different situation.....and it was probably dodgy solution anyway.

Cheers for any ideas.