How to close a "noisy" circular shape?

edited March 2018 in Python Mode

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)
Tagged:

Answers

  • edited March 2018

    Ok, so this snippet below do the trick BUT I still don't really get what I'm doing.

        def setup():
            size(600, 600)
    
        def draw():
            background(255)
    
            n_points = 300
            angle = radians(360) / n_points
            radius = 300
            t = .8
    
            beginShape()
            strokeWeight(4)
            for e in range(n_points):
                x = cos(angle * e) * radius
                y = sin(angle * e) * radius 
                p = PVector(x, y).normalize()
                n = map(noise(p.x + t, p.y + t), 0, 1, 70, 120)
                p.mult(n*2)
                vertex(width / 2 + p.x, height / 2 + p.y)
            endShape(CLOSE)
    

    (Click here to see the motion generated by the noise) IMAGE ALT TEXT HERE

    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 of someValue -- 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.

Sign In or Register to comment.