Well, it's hard to make a suitable suggestion without looking at all of the code, because I don't know if, how and where loopnum is getting used.
Previously, you were just using "1" here, right? That's the interval between terrain samples, right?
I would suggest not to use a floating point value as the index. Even without changing much of your code, there are simple workarounds - such as simply multiplying loopnum by a factor of 10 and then changing your code to undo this:
- Code: Select all
var xoffset = (me.loopnum/10) * math.sin(heading);
var yoffset = (me.loopnum/10) * math.cos(heading);
But the truth is, it would be better to uncouple the indexing and the sampling interval by using an additional variable instead.
So, you could still name your samples 0..99 but do them in 0.5 nm increments instead, without the interval affecting the index.