# How to do this programmatically (Combinatorics?)

**URL:** <https://discourse.processing.org/t/how-to-do-this-programmatically-combinatorics/38847>\
**Category:** Coding Questions\
**Created:** [September 18, 2022, 10:18pm UTC](https://discourse.processing.org/t/how-to-do-this-programmatically-combinatorics/38847 "2022-09-18T22:18:39Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 17, 2024, 12:16pm UTC](https://discourse.processing.org/t/how-to-do-this-programmatically-combinatorics/38847/10 "2024-06-17T12:16:39Z")

</div>

Hello,

My original code with some updates from feedback:

```auto
/*
 Project: Polygons
 Author: GLV
 Date: 2024-06-17
 Version: 1.0.1
*/

size(300, 300);
translate(width/2, height/2);

int num = 7;
PVector [] v = new PVector [num];
int r = 100;

for(int i = 0; i<num; i++)
  {
  float angle = i*TAU/num - TAU/4;  
  float x = round(r*cos(angle));
  float y = round(r*sin(angle)); 
  v[i] = new PVector(x, y);
  }

strokeWeight(3);

for(int i = 0; i < num-1; i++) // Updated
  {
  for(int j = i+1; j < num; j++)
    {
    println(i,j, ':', v[i], v[j]);
    line(v[i].x, v[i].y, v[j].x, v[j].y);
    }
  }

```

Rounding was for a clean console output (less decimal places) for the screen grab and rounding to nearest pixel will not be noticeable.

I had some fun with this back when and once again and posted in the gallery:

> [@Polygon Exploration](https://discourse.processing.org/t/polygon-exploration/44606):
>
> Some fun with polygons! /\* Project: Polygons Author: GLV Date: 2024-06-17 Version: 1.0.0 \*/ int choice, seed; int id, idlast, sb, num, mxvs; int counter; PVector[] v; boolean warning = true; void settings() { size(400, 400, P2D); } void setup() { background(0); strokeWeight(2); noLoop(); } void draw() { background(0); translate(width/2, height/2); int vs = 10; // 1 to max vertices int sp = 5; …

`:)`

---

_[View the full topic](https://discourse.processing.org/t/how-to-do-this-programmatically-combinatorics/38847)._
