# Spreading out points

**URL:** <https://discourse.processing.org/t/spreading-out-points/19980>\
**Category:** Coding Questions\
**Created:** [April 21, 2020, 2:13am UTC](https://discourse.processing.org/t/spreading-out-points/19980 "2020-04-21T02:13:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuyu\_hakusho](https://avatars.discourse-cdn.com/v4/letter/y/dec6dc/32.png) [@yuyu\_hakusho](https://discourse.processing.org/u/yuyu_hakusho)\
**Post date:** [April 21, 2020, 2:13am UTC](https://discourse.processing.org/t/spreading-out-points/19980/1 "2020-04-21T02:13:53Z")

</div>

Hi everyone, I need some help with the traveling salesman problem. The issue I am having is that the (x, y) points of each city are too close to each other. As such, I get the result in the image below. Is there a way I could “spread the points” while retaining the relative distance? I tried using scale, but it goes out of the window. Thanks!

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/cae6462349ffe4547ac78f4f7f39a75892ce4e4b.png)

---

<div class="post-metadata">

**Author:** ![tony](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tony/32/949_2.png) [@tony](https://discourse.processing.org/u/tony)\
**Post date:** [April 21, 2020, 3:15am UTC](https://discourse.processing.org/t/spreading-out-points/19980/2 "2020-04-21T03:15:10Z")

</div>

Welcome to the forums!

Are you saying you already tried using the [scale()](https://processing.org/reference/scale_.html) function? I think this should do the trick.  
You can also try to multiply each point’s coordinates by a factor of x, which will preserve the original coordinates. Something like:

```auto
int x = 50;
int y = 65;

void draw(){
    point(x * 2, y * 2)
}

```

Either way, this is gonna “move” them away from `(0,0)`, so you’ll want to look into [translate()](https://processing.org/reference/translate_.html) and shift them back into view.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 21, 2020, 6:04am UTC](https://discourse.processing.org/t/spreading-out-points/19980/3 "2020-04-21T06:04:46Z")

</div>

When you get the points by random you can also increase the value in random

---

<div class="post-metadata">

**Author:** ![yuyu\_hakusho](https://avatars.discourse-cdn.com/v4/letter/y/dec6dc/32.png) [@yuyu\_hakusho](https://discourse.processing.org/u/yuyu_hakusho)\
**Post date:** [April 21, 2020, 3:49pm UTC](https://discourse.processing.org/t/spreading-out-points/19980/4 "2020-04-21T15:49:18Z")

</div>

Got it. Thank you so much!!
