cosine static method
Generate random terrain using the Cosine waves.
Parameters are the same as those for {@link static DiamondSquare}.
Implementation
static void cosine(Float32List g, TerrainOptions options) {
final amplitude = (options.maxHeight! - options.minHeight!) * 0.5,
frequencyScalar = options.frequency * math.pi / (math.min(options.xSegments, options.ySegments) + 1),
phase = math.Random().nextDouble() * math.pi * 2;
for (int i = 0, xl = options.xSegments + 1; i < xl; i++) {
for (int j = 0, yl = options.ySegments + 1; j < yl; j++) {
g[j * xl + i] += amplitude * (math.cos(i * frequencyScalar + phase) + math.cos(j * frequencyScalar + phase));
}
}
}