CodingTrain / CodingTrain/Suggestion-Box

Coding Challange: the Barnes-Hut algorithm

Open
#245 1 comment 4 reactions 0 assignees View on GitHub
Patron Recommended
Dominant language
No language data
Stars
570
Forks
85
PR merge metrics
No merged PRs in 30d

Description

You enjoy writing code that implement physical ideas, so I think the Barnes-Hut algorithm is a great idea.

In short, if we have a system of N particles, all of them interact with each other, than per iteration we would need to perform N^2 calculations, and the complexity would thus be O(N^2). The Barnes-Hut algorithm pushes this down to O(N*LogN), by constructing a quad-tree (or an oct-tree in 3D), each node of which represents a quadrant (or an octant) of the simulation area of the level above it. You sub-divide the simulation area recursively until you get only one particle per node, calculating the center-of-mass and total mass for every node, and then calculate the forces acting on each particle by reaching down the tree only to a certain point (such that far away objects are calculated as clusters, and only close enough objects are calculated one by one).

This allows you to simulate ten of thousands (if not millions) of particles in real-time! It's also how they make those galaxy simulations.

Read more about it [here](http://www.cs.princeton.edu/courses/archive/fall03/cs126/assignments/barnes-hut.html).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.