Skip to main content

Class: kdTree

physics/fluid/kdTree.kdTree

Represents a kdTree that contains Particles.

Constructors

constructor

โ€ข new kdTree(particles)

Creates a kdTree.

Parameters

NameTypeDescription
particlesParticle[]The particles to add to the tree

Defined in

src/physics/fluid/kdTree.ts:37

Properties

root

โ€ข root: kdNode

Defined in

src/physics/fluid/kdTree.ts:30

Methods

build

โ–ธ build(particles, depth?): kdNode

Builds the kdTree.

Parameters

NameTypeDefault valueDescription
particlesParticle[]undefinedThe particles to add to the tree
depthnumber0-

Returns

kdNode

Defined in

src/physics/fluid/kdTree.ts:46


findNeighbours

โ–ธ findNeighbours(particle, dist, distSqr): Particle[]

Finds all the neighbours of a particle within the given distance.

Parameters

NameTypeDescription
particleParticleThe particle to find neighbours of
distnumberThe maximum distance a neighbour can be from the particle
distSqrnumberThe maximum distance squared a neighbour can be from the particle

Returns

Particle[]

Defined in

src/physics/fluid/kdTree.ts:81


findNeighboursHelper

โ–ธ Private findNeighboursHelper(particle, pos, dist, distSqr, node, depth, neighbours): void

Parameters

NameType
particleParticle
posvec2
distnumber
distSqrnumber
nodekdNode
depthnumber
neighboursParticle[]

Returns

void

Defined in

src/physics/fluid/kdTree.ts:88