Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Divide the world into square bins of width 256. For each ball, put it in its appropriate bin. Then for each bin, check for collisions

Divide the world into square bins of width 256. For each ball, put it in its appropriate bin. Then for each bin, check for collisions where either both balls are in the bin, or one ball is in the bin, and the other ball is in an adjacent bin.

Implement the detect collisions algorithm described above.

Your new code must still find all the same collisions found by the old code (any pair of balls for which colliding returns true). To check that you are detecting the same collisions, run your code and the original code with the same parameters, and make sure that they detect the same number of collisions.

In your documentation, do not assume that the reader has read this problem set. The old code is provided below.

Using your improved code, after 1000 timesteps with 200 balls, how many collisions did you get? How many simulation steps per second did you run? How many simulation steps per second could you run with the original code and the same number of balls?

Link to the old code (Not the whole thing is important): https://pastebin.com/We9hgekG

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions