nature-of-code / The-Nature-of-Code-archive

The very first build system for The Nature of Code
http://natureofcode.com
913 stars 151 forks source link

Perlin Noise: Using map() unnecessarily? #363

Closed pamelafox closed 10 years ago

pamelafox commented 10 years ago

This feedback came from a tester of the Khan port of Nature of Code:

Noise always returns 0-1 - Mapping to any range would simply be n * + much like the formula for deviation in the Randomness section: num * standardDeviation + mean. It would seem in this case using map() is overkill.

Example code: this.x = map(noise(this.tx), 0, 1, 0, width); this.y = map(noise(this.ty), 0, 1, 0, height);

Compared to: this.x = noise(this.tx) * width; this.y = noise(this.ty) * height;

What's the motivation for using map()?

shiffman commented 10 years ago

no reason! I was probably just demonstrating how map() works at one point. Feel free to adjust.