nature-of-code / noc-examples-processing

Repository for example code from The Nature of Code book
MIT License
2.56k stars 951 forks source link

investigate strange behavior 2.3 #46

Open shiffman opened 10 years ago

shiffman commented 10 years ago

http://video.natureofcode.com/2.3/#comment-1250341006

ybakos commented 10 years ago

I can no longer reproduce the issue ever since commit 38b836ccf changed the window size to 640 x 360.

To reproduce the issue, run Example 2.3, but set the size of the window to, say 800 x 200.

The root cause of the issue is floating point related. Some of the Movers have an initial velocity.y of 0.10000001, while the majority have an initial velocity.y of 0.1. Because of this, the position of those Movers with the former velocity changes differently than the majority, and we see this difference compound over time: that small minority of Movers bounce differently than the rest.

This is by no means a show-stopping bug, but I am dying to understand the initial cause of the velocity difference and why the phenomena doesn't manifest when the screen size is, say 640 x360.