# Constellation with noise

**URL:** <https://discourse.processing.org/t/constellation-with-noise/36965>\
**Category:** Coding Questions\
**Created:** [May 19, 2022, 2:28pm UTC](https://discourse.processing.org/t/constellation-with-noise/36965 "2022-05-19T14:28:42Z")\
**Posts on this page:** 10\
**Page:** 2

<div class="post-metadata">

**Author:** ![humano](https://avatars.discourse-cdn.com/v4/letter/h/dbc845/32.png) [@humano](https://discourse.processing.org/u/humano)\
**Post date:** [May 23, 2022, 1:33am UTC](https://discourse.processing.org/t/constellation-with-noise/36965/21 "2022-05-23T01:33:55Z")

</div>

Yes , definitely , now It is working perfectly, there was my mistake surely

---

<div class="post-metadata">

**Author:** ![The\_Traveler](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/the_traveler/32/16252_2.png) [@The\_Traveler](https://discourse.processing.org/u/The_Traveler)\
**Post date:** [May 23, 2022, 1:38am UTC](https://discourse.processing.org/t/constellation-with-noise/36965/22 "2022-05-23T01:38:30Z")

</div>

Good news then. A small favor, repost your working code if you please. I’d like to be sure I have the latest to work with. Thanks.

---

<div class="post-metadata">

**Author:** ![humano](https://avatars.discourse-cdn.com/v4/letter/h/dbc845/32.png) [@humano](https://discourse.processing.org/u/humano)\
**Post date:** [May 23, 2022, 2:17am UTC](https://discourse.processing.org/t/constellation-with-noise/36965/23 "2022-05-23T02:17:13Z")

</div>

Of course. This is my trying rotate and translate, that duplicate the constellation

```auto
float u = 0;
float v = 0;
size(1000,1000);
background(255);
strokeCap(ROUND);

//first pattern

stroke(255,0,255);
for (int x = 0; x < 1000; x += 30) {
for (int y = 0; y < 1000; y += 30) {
u = u + 0.1;
v = v + 0.11;
float n = noise(u) * 500;
float m = noise(v) * 500;
strokeWeight(random(3,5));
translate(600,600);
rotate(PI/2.0);
point(n, m);

} 

}

```

And this is me trying setLocation , that is something that I don’t manage to run

```auto
void setup(){
float u = 0;
float v = 0;
size(1000,1000);
background(255);
strokeCap(ROUND);

surface.setResizable(true); 
surface.setSize(300, 200); 
surface.setLocation(300,300);

}

//first pattern

void draw() {

stroke(255,0,255);
for (int x = 0; x < 1000; x += 30) {
for (int y = 0; y < 1000; y += 30) {
u = u + 0.1;
v = v + 0.11;
float n = noise(u) * 500;
float m = noise(v) * 500;
strokeWeight(random(3,5));
point(n, m);

} 
}
}

```

---

<div class="post-metadata">

**Author:** ![The\_Traveler](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/the_traveler/32/16252_2.png) [@The\_Traveler](https://discourse.processing.org/u/The_Traveler)\
**Post date:** [May 23, 2022, 4:11am UTC](https://discourse.processing.org/t/constellation-with-noise/36965/24 "2022-05-23T04:11:28Z")

</div>

Thanks. Evidently, setLocation() doesn’t work the way I expected it to so there has to be another workaround.

---

<div class="post-metadata">

**Author:** ![humano](https://avatars.discourse-cdn.com/v4/letter/h/dbc845/32.png) [@humano](https://discourse.processing.org/u/humano)\
**Post date:** [May 23, 2022, 12:30pm UTC](https://discourse.processing.org/t/constellation-with-noise/36965/25 "2022-05-23T12:30:46Z")

</div>

If I chance noise function from 500 to width I think that rotate and translate does not work the same way

```auto
loat u = 0;
float v = 0;
size(1000,1000);
background(255);
strokeCap(ROUND);

//first pattern

stroke(255,0,255);
for (int x = 0; x < 1000; x += 30) {
for (int y = 0; y < 1000; y += 30) {
u = u + 0.1;
v = v + 0.11;
float n = noise(u) * width;
float m = noise(v) * width;
strokeWeight(random(3,5));
translate(900,900);
rotate(PI/3.0);
point(n, m);

} 

}

```

---

<div class="post-metadata">

**Author:** ![The\_Traveler](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/the_traveler/32/16252_2.png) [@The\_Traveler](https://discourse.processing.org/u/The_Traveler)\
**Post date:** [May 23, 2022, 2:23pm UTC](https://discourse.processing.org/t/constellation-with-noise/36965/26 "2022-05-23T14:23:28Z")

</div>

This is as close as I can get for now. I changed a few variables, added a couple of functions and tweaked things a bit. You might experiment more with the noise() function and see if you can get your dot distribution to your liking. Mapping x,y from u,v isn’t perfect and could be improved but the base code is sound. It takes a bit longer to run due to the extra random() functions I added. Haven’t spent anymore time on setLocation() but I’ll see if I have time later. 🙂

```auto
float u = 0;
float v = 0;
float x1, x2, x3, x4;
float y1, y2, y3, y4;

void setup() {
    size(1000,1000);
    background(255);
    strokeCap(ROUND);

    x1 = 300;
    y1 = 500;
    x2 = 800;
    y2 = 600;
    x3 = 700;
    y3 = 900;
    x4 = 400;
    y4 = 800;
    quad (x1,y1, x2,y2, x3,y3, x4,y4);
}

void draw() {
stroke(255,0,255);
float noiseScale = 0.1;
for (int x = 0; x < 500; x += 30) {
    for (int y = 0; y < 500; y += 30) {
        noiseDetail(4);
        u = u + 1.0 * noiseScale;
        v = v + 1.0 * noiseScale;

float n = noise(u,v) * random(x1,height);
float m = noise(u,v) * random(y1,width);

if (((( n > x1)) && (( m > y1))) && ((( n < x2)) && (( m > y2))) \
    && ((( n < x3)) && (( m < y3))) && ((( n > x4)) && (( m > y4)))) {

        strokeWeight(random(3,5));
        point(n, m-150);
        }
        else
               ;
        }
    }
}
    
    

```

---

<div class="post-metadata">

**Author:** ![humano](https://avatars.discourse-cdn.com/v4/letter/h/dbc845/32.png) [@humano](https://discourse.processing.org/u/humano)\
**Post date:** [May 23, 2022, 2:48pm UTC](https://discourse.processing.org/t/constellation-with-noise/36965/27 "2022-05-23T14:48:02Z")

</div>

Thank you so much for your effort, I really apreciate it. This is a good solution, but void draw makes an animation instead a static image and the result is a little different than centered constellation from the beginning. By the way, I think that I found something for sizes with noise , with @Mikey83 's help.

```auto
float u = 0;
float v = 0;
float w = 0;
size(1000,1000);
background(255);
strokeCap(ROUND);

//first pattern

stroke(255,0,255);
for (int x = 0; x < 1000; x += 30) {
for (int y = 0; y < 1000; y += 30) {
u = u + 0.1;
v = v + 0.11;
w = w + 0.1;

float n = noise(u) * width;
float m = noise(v) * width;
float l = noise(x/100.0, y/100.0)*10;

strokeWeight(l);
point(n, m);

  
}
}

```

Now I see that rotate and translate could work if I type them before the loop

```auto
float u = 0;
float v = 0;
size(1000,1000);
background(255);
strokeCap(ROUND);

//first pattern

stroke(255,0,255);
translate(200,200);
rotate(PI/8);
for (int x = 0; x < 1000; x += 30) {
for (int y = 0; y < 1000; y += 30) {
u = u + 0.1;
v = v + 0.11;
float n = noise(u) * 500;
float m = noise(v) * 500;
strokeWeight(random(3,5));
point(n, m);

} 

}

```

---

<div class="post-metadata">

**Author:** ![Mikey83](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mikey83/32/17956_2.png) [@Mikey83](https://discourse.processing.org/u/Mikey83)\
**Post date:** [May 23, 2022, 2:56pm UTC](https://discourse.processing.org/t/constellation-with-noise/36965/28 "2022-05-23T14:56:10Z")

</div>

Thanks for the mention mate, also dont forget, you can always remap any value to any other value with the map() function, can be used instead of multiplying the variable l by 10

---

<div class="post-metadata">

**Author:** ![The\_Traveler](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/the_traveler/32/16252_2.png) [@The\_Traveler](https://discourse.processing.org/u/The_Traveler)\
**Post date:** [May 23, 2022, 3:23pm UTC](https://discourse.processing.org/t/constellation-with-noise/36965/29 "2022-05-23T15:23:25Z")

</div>

> [@humano](#):
>
> void draw makes an animation instead a static image

That’s strange. After the code runs to completion it can be saved as a static image. Glad Mikey brought map() up, hadn’t thought of it. Well, glad to help and you’re well on your way. I won’t be on much this week as my wife and I have a lot of commitments. I’ll check in on your progress and see if I can get setLocation() worked out. Cheers.

---

<div class="post-metadata">

**Author:** ![Mikey83](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mikey83/32/17956_2.png) [@Mikey83](https://discourse.processing.org/u/Mikey83)\
**Post date:** [May 24, 2022, 2:26am UTC](https://discourse.processing.org/t/constellation-with-noise/36965/30 "2022-05-24T02:26:39Z")

</div>

Hi again, reading through what you have been trying to do, the surface.setLocation() changes the location of the window itself nothing on the canvas im pretty sure, also, if you want to change the position of the points, add a offset value to the point itself, so

```auto
point(n+someValue, m+someValue);

```

hope that helps

[Previous page](https://discourse.processing.org/t/constellation-with-noise/36965.md?page=1)
