We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have a code that draws a line inside a for loop in void draw()
and it works fine, until the number of iterations of the loop times the number of frames equals 25,000,000. Then the line displays incorrectly. For example:
Using for (int i=0; i<=5000; i++)
it stops displaying correctly at FrameCount = 5000
(5,000 * 5,000 = 25,000,000).
Using for (int i=0; i<=10000; i++)
it stops displaying correctly at FrameCount = 2500
(10,000 * 2500 = 25,000,000).
Using for (int i=0; i<=50000; i++)
it stops displaying correctly at FrameCount = 500
(50,000 * 500 = 25,000,000).
Is there a way to just keep it running properly? Thanks.
Answers
can you post a runnable example? something minimal that shows the problem, something we can run
Sure @koogs, here it is:
beware printing too much to the console - it'll lock up your computer (as it has just done to mine)
i put a couple of lines of debug (enabled by keypress) that showed x, y, oldX and oldY and pressed the button after it stopped displaying and it showed that x and oldX and y and oldY were the same. i think it stops drawing because it's drawing a 0 length line. but i could be wrong - because my computer locked up and i'm wary of running it again 8)
i wonder if it's a precision problem, that adding and multiplying by such small values is causing problems.
yeah, look, the last three values it printed before i stopped it:
theta isn't increasing, x and y aren't changing...
I think the problem could be in the size of theta, because the last value is 1048576, and a MB = 1048576 B.
What do you think? Is there a way to fix this?
@ koogs Thanks for taking the time