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

The very first build system for The Nature of Code

Home Page:http://natureofcode.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Perlin Noise: Using map() unnecessarily?

pamelafox opened this issue · comments

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()?

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