A Rust implementation of the Barnes-Hut tree in 3 dimensions.
This implementation focuses on the use of Rusts's enumerations to describe multiple coordniate systems, as well as the tree structure that forms the heart of the algorithm.
A detailed discussion on the Barnes-Hut algorithm is given here.
The main components of this implementation are:
Point <enum>
Bounds <struct>
Body <struct>
BHTree <enum>
There are 3 available coordinate systems to choose from:
Cartesian
:x
,y
,z
Cylindrical
:r
,phi
,z
Spherical
:rho
,phi
,theta
These are determined at the Point
level (as variants of the enumeration), and,
for the most part, cannot be interchanged. The chosen system is used to describe
the limits of the Bounds
instances and the centre of mass of the Body
instances and tree nodes.
Based on the algorithm, the BHTree
enumeration has 3 variants:
Empty
: a tree node with no constituentBody
instancesNode
: a tree node with exactly one consitientBody
instanceNodes
: a tree node with child nodes