Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Is noise() broken?

in Bugs Posts: 425

On my iPad (air 2), the this code print(noise(0,5.6,-0.3)) outputs -1.1665666103363, but the reference states that noise Outputs values between -1 and 1.

Is this a bug or am I missing something?

Comments

  • dave1707dave1707 Mod
    Posts: 7,312

    @Coder It's possible that noise is broken, but I don't have access to the code to say for sure one way or the other. Here's a program that takes the values of x,y,z in a range from -1 to 1 in increments of .1 . The green line show a valid noise value where z is 0 for each value of x,y. So when z is 0, the noise value is in the -1 to 1 range for all values of x,y. The diagonal line shows z values from -1 to 1 (lower left to upper right). It's white where the noise value is in the range from -1 to 1 and red if the noise value is less than -1 or greater than 1. As you can see, there aren't very many x,y,z values where the noise value stays in the -1 to 1 range.

    supportedOrientations(LANDSCAPE_ANY)
    displayMode(FULLSCREEN)
    
    function setup()
        xOffset=500
        yOffset=400
        xSize=340
        ySize=340
    end
    
    function draw()
        background(0)
        for x=-1,1,.1 do
            for y=-1,1,.1 do
                for z=-1,1,.1 do
                    v=noise(x,y,z)
                    fill(255)
                    if z>-.05 and z<.05 then
                        fill(39, 255, 0, 255)
                        ellipse(x*xSize+xOffset,y*ySize+yOffset,30,2)
                    else
                        fill(255)
                        if v<-1 or v>1 then
                            fill(255,0,0)
                        end
                        ellipse(x*xSize+xOffset+(z*8)*-1,y*ySize+yOffset+(z*16)*-1,5,5)
                    end
                end
            end
        end
        fill(255)
        for v=-1,1,.1 do
            text(string.format("%.1f",v),v*xSize+xOffset-5,yOffset-370)
            text(string.format("%.1f",v),xOffset-370,v*ySize+yOffset)
        end
    end
    
  • Posts: 425

    @dave1707 Thanks for the example - I'll just stick to 2d noise then :)

Sign In or Register to comment.