Lattice¶
Overview¶
The lattice is a 2D grid with a value in each cell that represents the wave amplitude at that point.
@author Sam Reid (PhET Interactive Simulations)
Class Lattice¶
Constructor¶
new Lattice( width : number, height : number, dampX : number, dampY : number )¶
Instance Methods¶
getBounds() : Bounds2¶
Gets a Bounds2 representing the full region of the lattice, including damping regions.
visibleBoundsContains( i : number, j : number ) : boolean¶
Returns true if the visible bounds contains the lattice coordinate @param i - integer for the horizontal coordinate @param j - integer for the vertical coordinate
contains( i : number, j : number ) : boolean¶
Returns true if the given coordinate is within the lattice @param i - integer for the horizontal coordinate @param j - integer for the vertical coordinate
getCenterLineValues( array : number[] )¶
Read the values on the center line of the lattice (omits the out-of-bounds damping regions), for display in the WaveAreaGraphNode @param array - array to fill with the values for performance/memory, will be resized if necessary
getCurrentValue( i : number, j : number ) : number¶
Returns the current value in the given cell, masked by the allowedMask. @param i - horizontal integer coordinate @param j - vertical integer coordinate
getInterpolatedValue( i : number, j : number ) : number¶
Returns the interpolated value of the given cell, masked by the allowedMask. @param i - horizontal integer coordinate @param j - vertical integer coordinate
setCurrentValue( i : number, j : number, value : number )¶
Sets the current value in the given cell @param i - horizontal integer coordinate @param j - vertical integer coordinate @param value
setLastValue( i : number, j : number, value : number )¶
Sets the previous value in the given cell @param i - horizontal integer coordinate @param j - vertical integer coordinate @param value
setAllowed( i : number, j : number, allowed : boolean )¶
In order to prevent numerical artifacts in the point source scenes, we use TemporalMask to identify which cells have a value because of the source oscillation. @param i @param j @param allowed - true if the temporal mask indicates that the value could have been caused by sources
hasCellBeenVisited( i : number, j : number ) : boolean¶
Determines whether the incoming wave has reached the cell. @param i - horizontal coordinate to check @param j - vertical coordinate to check
clear()¶
Resets all of the wave values to 0.
clearRight( column : number )¶
Clear everything at and to the right of the specified column. @param column - integer index of the column to start clearing at.
getOutputColumn() : number[]¶
Gets the values on the right hand side of the wave (before the damping region), for determining intensity.
step()¶
Propagates the wave by one step. This is a discrete algorithm and cannot use dt.
Instance Properties¶
changedEmitter : Emitter¶
(readonly)
sends a notification each time the lattice updates.
interpolationRatio¶
Determines how far we have animated between the "last" and "current" matrices, so that we can use getInterpolatedValue to update the view at 60fps even though the model is running at a slower rate. See EventTimer.getRatio for more about this value.
visibleBounds : Bounds2¶
(readonly)
a Bounds2 representing the visible (non-damping) region of the lattice.
Static Properties¶
WAVE_SPEED¶
(readonly)
Source Code¶
See the source for Lattice.ts in the scenery-phet repository.