# Get counts from each cell in cavas in Processing

**URL:** <https://discourse.processing.org/t/get-counts-from-each-cell-in-cavas-in-processing/8238>\
**Category:** Coding Questions\
**Created:** [February 9, 2019, 6:24am UTC](https://discourse.processing.org/t/get-counts-from-each-cell-in-cavas-in-processing/8238 "2019-02-09T06:24:30Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [February 15, 2019, 6:06am UTC](https://discourse.processing.org/t/get-counts-from-each-cell-in-cavas-in-processing/8238/4 "2019-02-15T06:06:32Z")

</div>

For more on the grid based collision system approach with code examples, see:

> [@Implementing Grid-Based Collision System](https://discourse.processing.org/t/implementing-grid-based-collision-system/3248/5):
>
> The link below is for a Processing sketch I created which uses a quadtree data structure and allows the user to change the ball (moving object) size and configure some of the quadtree factors. You might like to try it. [QuadTreeDemo](http://lagers.org.uk/zzz/QuadtreeDemo-180904.zip) It requires the G4P library to be installed, can be done through the Contributions Manager [10]

…and previously [https://forum.processing.org/two/discussion/17830/how-do-i-iterate-through-individual-buckets-in-hashmaps](https://forum.processing.org/two/discussion/17830/how-do-i-iterate-through-individual-buckets-in-hashmaps)

…and also, see this chapter with code examples:

Ch.6 from Nature of Code – in particular section 6.14 “Algorithmic Efficiency (or: Why does my $@(\*%! run so slowly?)” [The Nature of Code](https://natureofcode.com/book/chapter-6-autonomous-agents/)  
… [noc-examples-processing/chp06\_agents/binlatticespatialsubdivision at master · nature-of-code/noc-examples-processing · GitHub](https://github.com/nature-of-code/noc-examples-processing/tree/master/chp06_agents/binlatticespatialsubdivision)

However note that these approaches do **not** satisfy “A ball is said to be in a cell if more than 50% of the area of the ball is within the cell.”

---

_[View the full topic](https://discourse.processing.org/t/get-counts-from-each-cell-in-cavas-in-processing/8238)._
