• Create Account

## Find nearest maximum to random location on 1D perlin noise function

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1zz2  Members

282
Like
0Likes
Like

Posted 11 September 2013 - 03:31 PM

Is it possible to find (approximate) nearest maximum of Perlin noise function for specific random value?

I draw this sketch to illustrate:

If red dot represents random offset on the Perlin noise function, is it possible to approximate where the nearest maximum is?

I would like for animation to always start at the top of the wave (so it always drops first).

### #2JTippetts  Moderators

12317
Like
1Likes
Like

Posted 11 September 2013 - 05:23 PM

If you calculate the derivative of the noise function you obtain a gradient value that indicates which way the function is going at X. That is, if the function is increasing at X, then the gradient will be positive, whereas if the function is decreasing the gradient will be negative. Local maxima/minima are places where the gradient is equal to 0. At those places, the function is neither increasing nor decreasing. So you can calculate the derivative at X, then iteratively "move" in the direction indicated by this gradient value (decrease X for negative gradient, increase X for positive) until the gradient approaches near enough to 0 to be considered "close enough". That should be your nearest maximum.

5832
Like
0Likes
Like

Posted 11 September 2013 - 06:07 PM

I think the Perlin noise function works on gradients anyway.

There is a local minima/maxima inbetween sample points if the sign of the derivative changes between sample points (since it is continuous).

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

### #4zz2  Members

282
Like
1Likes
Like

Posted 12 September 2013 - 01:18 AM

Thank you! That would work. I have implemented Perlin noise function that calculates derivative, from Gustavson's code. Then I realized the real cause of the problem was not the starting point on Perlin's function, but a bug in my code that caused that attenuation of magnitude (of my effect) was dependent on random offset on Perlin's function. I fixed it and now animation behaves as expected.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.