title: Porting classic Perlin Noise to JavaScript: Getting periodic pattern. Why? (JsFiddle example)
body: <p>I try to port classic Perlin Noise (src: <a href="http://mrl.nyu.edu/~perlin/doc/oscar.html#noise" rel="nofollow">http://mrl.nyu.edu/~perlin/doc/oscar.html#noise</a>) to JavaScript - for scientific purposes. I don't know why, but my code generates a periodic pattern instead of a random pattern.</p>
  
  <p>You can find my full code with an example drawn to canvas here (stripped down to one dimension): <a href="http://jsfiddle.net/YL77D/" rel="nofollow">http://jsfiddle.net/YL77D/</a></p>
  
  <p>I think the problem can be found within the "noise1" function:</p>
  
  <pre><code>sx = s_curve(rx0);
  
  u = rx0 * g1[ p[ bx0 ] ];
  v = rx1 * g1[ p[ bx1 ] ];
  
  return lerp(sx, u, v);
  </code></pre>
  
  <p>If my x-seed is 10.1, 10.2, 10.3, etc. I think u and v should be the same number (u should be based on 10 and v should be based on 11 - so sx is somewhere between). Am I right? But in my code u and v is allways different.</p>
  
  <p>Any ideas? Thank you very much.</p>