We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everyone !
When trying to draw a noisy circle I'm facing the following problem: the last vertex and the first vertex don't share the same position (due to the applied noise) so "closing" the circle becomes impossible:
How can I fix this ?
def setup():
size(600, 600)
def draw():
background(255)
n_points = 300
angle = radians(360) / n_points
radius = 300
beginShape()
strokeWeight(4)
for e in range(n_points):
n = noise(map(e, 0, n_points, 0, 3))
x = cos(angle * e) * radius * n
y = sin(angle * e) * radius * n
vertex(width / 2 + x, height / 2 + y)
endShape(CLOSE)
Answers
Ok, so this snippet below do the trick BUT I still don't really get what I'm doing.
(Click here to see the motion generated by the noise)
I've recently purchased the amazing "Generative Design" book by Benedikt Gross and found that he doesn't map the noise like I did in this snippet but rather apply noise to "map" (see first post).
In short, he writes something like:
noise(map(value,0,range,0,noiseRange)) * someValue
instead of:
map(noise(x, y), 0, 1, min, max)
Can someone please explain me the difference here ? And why this difference prevented me to close the first circle ?
Thank you.
I think the thing to focus on is how you get Perlin noise to give you repeating values. That's what you want -- a wobbly line that begins at the same height it ends, so that when wrapped in a circle there is no gap.
The basic answer to this question is that it is the ratio of period to octaves that gives you a repeating pattern. In 2D, it creates a "tile" that seemlessly matches its neighbors; in 1D it creates a wrapping line (or a circular outline).
Here is an in-depth discussion of how noise settings affect the way that Perlin noise repeats:
Regarding your specific code question:
Your use of map in
map(noise(x, y), 0, 1, min, max)
seems like it might be the equivalent to Gross's use ofsomeValue
-- it is for scaling the output:`noise(mappedValue) * someValue
His use of map inside noise looks different from yours... notice that map only returns one value, so Gross is only passing noise() a single argument to produce 1D noise.
Thanks a bunch Jeremy, you're the best.