《The Nature of Code》简介:

How can we capture the unpredictable evolutionary and emergent properties of nature in software? How can understanding the mathematical principles behind our physical world help us to create digital worlds? This book focuses on a range of programming strategies and techniques behind computer simulations of natural systems, from elementary concepts in mathematics and physics to more advanced algorithms that enable sophisticated visual results. Readers will progress from building a basic physics engine to creating intelligent moving objects and complex systems, setting the foundation for further experiments in generative design. Subjects covered include forces, trigonometry, fractals, cellular automata, self-organization, and genetic algorithms. The book's examples are written in Processing, an open-source language and development environment built on top of the Java programming language. On the book's website (http://www.natureofcode.com), the examples run in the browser via Processing's JavaScript mode.

《The Nature of Code》摘录:

perlin噪声算法可用于生成各种自然特效,包括云层、地形和大理石的纹理。 perlin噪声算法表现了一定的自然性,因为它能生成符合自然排序(“平滑”)的伪随机数的效果。 Processing内置了perlin噪声算法的实现:noise()函数。该函数返回的是0-1之间的数值,可以用map()函数来映射需要范围的数值。 新值=map(当前值,0,1,目标范围最小值,目标范围最大值)