pub struct BhTree<const D: usize> { /* private fields */ }Expand description
Barnes–Hut 树。build 之后可反复 repulsion。
Implementations§
Source§impl<const D: usize> BhTree<D>
impl<const D: usize> BhTree<D>
Sourcepub fn with_capacity(capacity: usize, theta: f32) -> Self
pub fn with_capacity(capacity: usize, theta: f32) -> Self
capacity 预留节点容量(约 8 倍点数),跨步复用避免重复分配。
pub fn clear(&mut self)
pub fn is_empty(&self) -> bool
Sourcepub fn repulsion(
&self,
p: [f32; D],
mass: f32,
self_idx: u32,
strength: f32,
min_dist: f32,
stack: &mut Vec<i32>,
out: &mut [f32; D],
)
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 由调用方复用(每步分配一次,非每节点)。
Sourcepub fn node_count(&self) -> usize
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>
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>
impl<const D: usize> UnsafeUnpin for BhTree<D>
impl<const D: usize> UnwindSafe for BhTree<D>where
RawVecInner: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more