addPlaneZ method

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

Implementation

void addPlaneZ( 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 z = 0; z < dist; z ++ ) {
    double zdiv = z / size;
    double zz = zdiv * zdiv;
    double val = strength / ( 0.0001 + zz ) - subtract;
    if ( val > 0.0 ) {
      int cz = zd * z;
      for (int y = 0; y < size; y ++ ) {
        int cyz = cz + y * yd;
        for (int x = 0; x < size; x ++ ){
          field[ cyz + x ] += val;
        }
      }
    }
  }
}