nature-of-code / noc-examples-processing

Repository for example code from The Nature of Code book

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

investigate strange behavior 2.3

shiffman opened this issue · comments

I can no longer reproduce the issue ever since commit 38b836c 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.