addPlaneY method

void addPlaneY(
  1. dynamic strength,
  2. dynamic subtract
)

Implementation

void addPlaneY( strength, subtract ) {
  // cache attribute lookups
  final size = this.size;
  final yd = this.yd;
  final zd = this.zd;
  final field = this.field;

  double dist = size * math.sqrt( strength / subtract );
  if ( dist > size ) dist = size;

  for (int y = 0; y < dist; y ++ ) {
    double ydiv = y / size;
    double yy = ydiv * ydiv;
    double val = strength / ( 0.0001 + yy ) - subtract;
    if ( val > 0.0 ) {
      int cy = y * yd;
      for (int x = 0; x < size; x ++ ) {
        int cxy = cy + x;
        for (int z = 0; z < size; z ++ ){
          field[ zd * z + cxy ] += val;
        }
      }
    }
  }
}