WallBoundary

WallBoundary is a simple Wall that is comprised of a straight-line between two spatial coordinates. Wall positions are generally meant to be immutable since the normal vector is calculated upon instantiation. However, wall position can be modified with some care.

Constructor

new WallBoundary(x1, y1, x2, y2, width)

Instantiates new WallBoundary

Parameters:
NameTypeDefaultDescription
x1*

x-position of first vertex

y1*

y-position of first vertex

x2*

x-position of second vertex

y2*

y-position of second vertex

width*1

rendered line width of wall (does not effect physics)

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>