Class

ForceGenerator

PhysicsEngine.ForceGenerator()

Force generators for physics system

Constructor

# new ForceGenerator()

View Source utils/physicsEngine.js, line 320

Methods

# static electromagnetic(particle1, particle2, k) → {Vector2D}

Electromagnetic force

Parameters:
Name Type Default Description
particle1 PhysicsParticle

First particle

particle2 PhysicsParticle

Second particle

k number 1

Coulomb's constant

View Source utils/physicsEngine.js, line 413

Electromagnetic force

Vector2D

# static gravity(strength) → {Vector2D}

Gravity force

Parameters:
Name Type Default Description
strength number 9.81

Gravity strength

View Source utils/physicsEngine.js, line 326

Gravity force

Vector2D

# static magneticField(fieldCenter, particlePos, strength) → {Vector2D}

Magnetic field force

Parameters:
Name Type Default Description
fieldCenter Vector2D

Center of magnetic field

particlePos Vector2D

Particle position

strength number 1

Field strength

View Source utils/physicsEngine.js, line 350

Magnetic force

Vector2D

# static spring(anchor, particlePos, restLength, stiffness) → {Vector2D}

Spring force

Parameters:
Name Type Default Description
anchor Vector2D

Spring anchor point

particlePos Vector2D

Particle position

restLength number 0

Spring rest length

stiffness number 0.1

Spring stiffness

View Source utils/physicsEngine.js, line 398

Spring force

Vector2D

# static turbulence(position, strength, time) → {Vector2D}

Turbulence force

Parameters:
Name Type Default Description
position Vector2D

Particle position

strength number 1

Turbulence strength

time number 0

Current time

View Source utils/physicsEngine.js, line 367

Turbulence force

Vector2D

# static vortex(center, particlePos, strength) → {Vector2D}

Vortex force

Parameters:
Name Type Default Description
center Vector2D

Vortex center

particlePos Vector2D

Particle position

strength number 1

Vortex strength

View Source utils/physicsEngine.js, line 380

Vortex force

Vector2D

# static wind(strength, direction) → {Vector2D}

Wind force

Parameters:
Name Type Default Description
strength number 1

Wind strength

direction number 0

Wind direction in radians

View Source utils/physicsEngine.js, line 336

Wind force

Vector2D