public float getConcentration(float x, float z) //"based" on the model from the article that Gustav sent us { float distPow2 = MathFloat.Pow(x - xCord, 2) + MathFloat.Pow(z - zCord, 2); //calculates the dist^2 just to make the next row more readable float c = i_0 + max * MathFloat.Exp(-distPow2 / d); //calculatates c return(c); }
//Method that returns the number of cells that are within a given distance of the given location //only to be used with cells that have a ForwardsInternals as their internals (since iteration does not make sense otherwise) public int GetNumOfCloseCells(int iteration, float distance, IPointAdapter location) { int num = 0; distance *= distance; //removes the need for sqrt operation foreach (Cell cell in cells[iteration]) { if (!(cell.GetInternals() is ForwardInternals)) { continue; } IPointAdapter cellLocation = ((ForwardInternals)cell.GetInternals()).GetPosition(iteration); if (MathFloat.Pow(cellLocation.GetX() - location.GetX(), 2) + MathFloat.Pow(cellLocation.GetZ() - location.GetZ(), 2) <= distance) { num++; } } return(num); }
public float GradZ(float x, float z) { float dist = -MathFloat.Pow(x - xCord, 2) - MathFloat.Pow(z - zCord, 2); return(-2 * MathFloat.Exp(dist / d) * (z - zCord) / d); }