User Tools

Site Tools


processing:compass_example

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
processing:compass_example [2013/08/03 04:14] mithatprocessing:compass_example [2015/08/01 21:11] (current) – [Refining randomness] mithat
Line 122: Line 122:
      
   // draw the compass at "ang" degrees plus or minus 0-4 random degrees   // draw the compass at "ang" degrees plus or minus 0-4 random degrees
-  drawCompass(ang+random(-4.0,4.0), 20, 200, width/2, height/2);+  drawCompass(ang + random(-4.0,4.0), 20, 200, width/2, height/2);
 }</code> }</code>
  
Line 131: Line 131:
 The offsets in the "Adding randomness" example above appear noticeably more jittery than a true natural process. This is because the random offsets are allowed to jump directly over the entire range that the indicator bounces within. The offsets in the "Adding randomness" example above appear noticeably more jittery than a true natural process. This is because the random offsets are allowed to jump directly over the entire range that the indicator bounces within.
  
-A random offset process can be smoothed out by //accumulating small random offsets// rather than jumping completely randomly over some range. The small random offsets will average out to zero in the long run, but they will prevent the indicator from jumping too far between any two frames. On the other hand, it's possible for the total offset to temporarily exceed the desired bounds.+A random offset process can be smoothed out by //accumulating small random offsets// rather than jumping completely randomly over some range. The small random offsets will average out to zero in the long run, but they will prevent the indicator from jumping too far between any two frames. The downsides are that it's possible for the total offset to temporarily exceed the desired bounds and that sometimes the accumulated offset can become so large that it never seems to return to zero.
  
 <code java> <code java>
Line 166: Line 166:
 [[http://mithatkonar.com/processing/compass/compass_noise/|{{:processing:processing_compass_noise.png?300}}]] [[http://mithatkonar.com/processing/compass/compass_noise/|{{:processing:processing_compass_noise.png?300}}]]
  
-[[https://en.wikipedia.org/wiki/Perlin_noise|Perlin noise]] is a mapping function that simulates natural random variations very wellWe refer to it as a mapping function because unlike Processing's ''[[http://processing.org/reference/random_.html|random]]'' function, which returns a new random value over a specified range each time you call it, Perlin noise has an input and an output. The input is some point in N-dimensional space, and the output is some value. Every time you invoke a Perlin noise function with the same input, you'll get the same output. If you shift the input slightly, the output value changes, and these changes are very similar to the kinds of changes found in nature.+[[https://en.wikipedia.org/wiki/Perlin_noise|Perlin noise]] is a **mapping function** that was designed to simulate natural random variations. It's called a mapping function because unlike Processing's ''[[http://processing.org/reference/random_.html|random]]'' function, which returns a new random value over a specified range each time you call it, Perlin noise has an input and an output. The input is some point in N-dimensional space, and the output is some value. Every time you invoke a Perlin noise function with the same input, you'll get the same output. If you shift the input slightly, the output value changes, and these changes are very similar to the kinds of changes found in nature.
  
-Processing has a function called ''[[http://processing.org/reference/noise_.html|noise]]'' that implements Perlin noise. We use the one-dimensional version of ''noise'' here to determine the offset of the indicator.+Processing has a function called ''[[http://processing.org/reference/noise_.html|noise]]'' that implements Perlin noise. We use the one-dimensional version of the ''noise'' function here to determine the offset of the indicator.
  
 <code java> <code java>
processing/compass_example.1375503280.txt.gz · Last modified: 2013/08/03 04:14 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki