Collision

Collision is a NearBehavior that calculates collision interactions between a particle and its nearby particles. Collisions operate on impulse-based dynamics and are quite stiff. There are some potential issues with collision instability when too much force / number of collisions stack. When encountering stability issues, consider the use of the PowderForce behavior.

Constructor

new Collision()

Instantiates new Collision behavior object

Extends

Methods

applyBehavior(particle, particles, timeStep)

Perform the collision update of a Particle by calculating impulse based velocity and position changes.

Parameters:
NameTypeDescription
particleParticle

particle with collision check

particlesArray.<Particle>

nearby particles that interact with particle

timeStepNumber

applyCorrection(particle, particles)

Performs the position-based correction after impulse collision. This ensures that particles are not stuck within each other.

Parameters:
NameTypeDescription
particleParticle

particle with collision check

particlesArray.<Particle>

nearby particles that interact with particle

range() → {null}

Returns the effective range / defines the size of the nearby range

Returns:
Type: 
null

(static) isCollide(p1, p2)

A static method that checks whether two particles are colliding

Parameters:
NameTypeDescription
p1Particle
p2Particle
Returns:

boolean