[][src]Struct nbody_barnes_hut::barnes_hut_3d::OctTree

pub struct OctTree { /* fields omitted */ }

Implementations

impl OctTree[src]

pub fn new(particles: &[&Particle3D], theta: f64) -> Self[src]

Constructs a tree from an array of particles. Also takes in theta, which - roughly speaking - describes how accurate the simulation should be. For more information, check here.

"Whether a node is or isn't sufficiently far away from a body, depends on the quotient s / d, where s is the width of the region represented by the internal node, and d is the distance between the body and the node's center of mass. The node is sufficiently far away when this ratio is smaller than a threshold value θ. The parameter θ determines the accuracy of the simulation; larger values of θ increase the speed of the simulation but decreases its accuracy. If θ = 0, no internal node is treated as a single body and the algorithm degenerates to a direct-sum algorithm."

A value of 0.5 is quite common.

pub fn update_theta(&mut self, theta: f64)[src]

pub fn calc_forces_on_particle<T: Copy, F: Fn(f64, f64, Vector3D, T) -> Vector3D + Copy>(
    &self,
    particle_position: Vector3D,
    other_attributes: T,
    calc: F
) -> Vector3D
[src]

Calculates the force on a particle.

Takes in the position of the particle, any attributes you wish to pass in, and a closure

The closure will need to take in the distance squared, the mass, the distance vector, and the other attributes which you passed in. It will need to return a force (or acceleration) vector Please note that the distance vector is not normalized! It is your responsibility to do this.

Auto Trait Implementations

impl RefUnwindSafe for OctTree

impl Send for OctTree

impl Sync for OctTree

impl Unpin for OctTree

impl UnwindSafe for OctTree

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.