RectangularWorldBoundary

RectangularWorldBoundary is a rectangular bounding box that constrains all particles within the boundaries. The implementation uses a strict uni-directional constraint, and particles cannot escape the world boundaries. Since the boundary is strict, the current implementation checks all particles contained in the boundaries, not just particles surrounding the edge.

Constructor

new RectangularWorldBoundary(minW, maxW, minH, maxH)

Parameters:
NameTypeDescription
minWNumber

left x position (smaller value)

maxWNumber

right x position (larger value)

minHNumber

top y position (smaller value)

maxHNumber

bottom y position (larger value)

Extends

Methods

applyCorrection(particles)

Applies positional corrections on particles (walls do not move)

Parameters:
NameTypeDescription
particlesArray.<Particle>

getHashDimensions() → {Array.<Number>}

Computes the dimensions of the item for the HashGrid.

Returns:
Type: 
Array.<Number>

getHashPos() → {Array.<Number>}

Computes the coordinate position for the item within the HashGrid, expects center position.

Returns:
Type: 
Array.<Number>

isCollide(particle) → {Boolean}

Checks if a Particle is colliding with the Wall

Parameters:
NameTypeDescription
particleParticle
Returns:

true if particle is colliding with wall

Type: 
Boolean

resolveCollisions(particles, timeStep)

Resolve the collisions between the surrounding particles and the Wall itself.

Parameters:
NameTypeDescription
particlesArray.<Particle>
timeStepNumber

vertices() → {Array.<Vector2D>}

Calculates the vertices of the wall

Overrides
Returns:
Type: 
Array.<Vector2D>