Constructor
new Field(width, height)
Create a Field
Parameters:
Name | Type | Description |
---|---|---|
width |
number | The width of the Field |
height |
number | The height of the Field |
Members
field :Array.<Array.<p5.Vector>>
2D field vector array.
Type:
- Array.<Array.<p5.Vector>>
particles :Particle
Particles stack.
Type:
Methods
addParticle(part)
Adds a particle to the field particles stack.
Calculates the new field vectors.
Parameters:
Name | Type | Description |
---|---|---|
part |
Particle | The particle to be added to the field. |
clear()
Empties the particle stack.
Zeros the field using Field#zeroField
draw(space, scale)
Draws the field vectors. Draws the particles creating the field.
Parameters:
Name | Type | Description |
---|---|---|
space |
number | The distance in pixels between each grid point. |
scale |
number | A scale factor that shortens or lengthens the field vectors that are drawn. |
popParticle()
Pops particle from the fields particles stack.
Recalculates the field with the particle gone.
zeroField() → {Array.<Array.<p5.Vector>>}
Creates field array where all values are a zero vector.
Returns:
The 2D array containing the zero
field vectors.
- Type
- Array.<Array.<p5.Vector>>