Skip to main content

BhTree

Struct BhTree 

Source
pub struct BhTree<const D: usize> { /* private fields */ }
Expand description

Barnes–Hut 树。build 之后可反复 repulsion。

Implementations§

Source§

impl<const D: usize> BhTree<D>

Source

pub fn with_capacity(capacity: usize, theta: f32) -> Self

capacity 预留节点容量(约 8 倍点数),跨步复用避免重复分配。

Source

pub fn clear(&mut self)

Source

pub fn is_empty(&self) -> bool

Source

pub fn build(&mut self, points: &[[f32; D]], masses: &[f32])

用质点集重建。质点顺序任意;同位置重合点由深度上限兜底。

Source

pub fn repulsion( &self, p: [f32; D], mass: f32, self_idx: u32, strength: f32, min_dist: f32, stack: &mut Vec<i32>, out: &mut [f32; D], )

计算 p(质量 mass)受到的排斥力累积到 out。self_idx 跳过自身。 力模型:库仑式 F = strength · m_i · m_j / d²,沿 com → p 方向排斥, min_dist 软化避免除零。stack 由调用方复用(每步分配一次,非每节点)。

Source

pub fn node_count(&self) -> usize

测试 / 验证用:节点总数。

Auto Trait Implementations§

§

impl<const D: usize> Forget for BhTree<D>

§

impl<const D: usize> Freeze for BhTree<D>
where *const u8 is !null: Freeze, PhantomData<BhNode<D>>: Freeze,

§

impl<const D: usize> Move for BhTree<D>

§

impl<const D: usize> RefUnwindSafe for BhTree<D>

§

impl<const D: usize> Send for BhTree<D>
where RawVecInner: Send,

§

impl<const D: usize> Sync for BhTree<D>
where RawVecInner: Sync,

§

impl<const D: usize> Unpin for BhTree<D>
where *const u8 is !null: Unpin,

§

impl<const D: usize> UnsafeUnpin for BhTree<D>
where *const u8 is !null: UnsafeUnpin, PhantomData<BhNode<D>>: UnsafeUnpin,

§

impl<const D: usize> UnwindSafe for BhTree<D>
where RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.