# Algorithm for dividing a circle, providing labels for only some of the divisions

**URL:** <https://discourse.processing.org/t/algorithm-for-dividing-a-circle-providing-labels-for-only-some-of-the-divisions/25138>\
**Category:** Coding Questions\
**Created:** [November 2, 2020, 6:57pm UTC](https://discourse.processing.org/t/algorithm-for-dividing-a-circle-providing-labels-for-only-some-of-the-divisions/25138 "2020-11-02T18:57:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddownn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ddownn/32/2731_2.png) [@ddownn](https://discourse.processing.org/u/ddownn)\
**Post date:** [November 2, 2020, 6:57pm UTC](https://discourse.processing.org/t/algorithm-for-dividing-a-circle-providing-labels-for-only-some-of-the-divisions/25138/1 "2020-11-02T18:57:07Z")

</div>

I am trying to find a reusable algorithm for dividing any integer quantity into an integer number of parts, but providing a label for only some of those parts.

For example, numbers on a clock. I have the following, `numeral` gives the typical numbers on a clock.

I want `numeral2` to also start with `maxNumeral`, but with what I have so far, it is always 0. I’m having trouble working out how to do this, so I was hoping someone might be able to help.

I’d prefer if it was just a single formula that would work for all cases and not split into two assignments like this.

Thanks for any advice

```auto
int maxNumeral = 12; // the highest numeral on the dial
int divisions = 4; // number of parts to divide the dial into
int numeral = maxNumeral; // starting numeral

for (int i = 0; i < maxNumeral; i++) {
   numeral = ((numeral + (maxNumeral - 1)) % maxNumeral) + 1;
   //println(numeral); // 12, 1, 2, 3 ... 11
   
   int numeral2 = ((numeral * maxNumeral) / divisions) % maxNumeral;
   println(numeral2); // 0, 3, 6, 9
   
   numeral++;
}

```

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [November 3, 2020, 8:29am UTC](https://discourse.processing.org/t/algorithm-for-dividing-a-circle-providing-labels-for-only-some-of-the-divisions/25138/2 "2020-11-03T08:29:00Z")

</div>

Hi,

I don’t really understand what you want to achieve, but it looks too complicated. How about this :

```auto
int divisions = 4;
int maxNumeral = 12;
int numeral = maxNumeral;
int numeral2 = maxNumeral;

for(int i = 0; i < maxNumeral; i++) {
  println("numeral1 : " + numeral);
  numeral = (numeral + 1) % maxNumeral;
}

println("\n");

for(int i = 0; i < divisions; i++) {
  println("numeral2 : " + numeral2);
  numeral2 = (numeral2 + (maxNumeral / divisions)) % maxNumeral;
}

```

Output :

```auto
numeral1 : 12
numeral1 : 1
numeral1 : 2
numeral1 : 3
numeral1 : 4
numeral1 : 5
numeral1 : 6
numeral1 : 7
numeral1 : 8
numeral1 : 9
numeral1 : 10
numeral1 : 11

numeral2 : 12
numeral2 : 3
numeral2 : 6
numeral2 : 9

```

---

<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:** [November 3, 2020, 10:07am UTC](https://discourse.processing.org/t/algorithm-for-dividing-a-circle-providing-labels-for-only-some-of-the-divisions/25138/3 "2020-11-03T10:07:15Z")

</div>

Do you mean circle in a graphical sense?

Then also look website | tutorials | trigonometry please

Chrisir

---

<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:** [November 3, 2020, 11:01am UTC](https://discourse.processing.org/t/algorithm-for-dividing-a-circle-providing-labels-for-only-some-of-the-divisions/25138/4 "2020-11-03T11:01:09Z")

</div>

Hello,

This came to mind:

```auto
//https://discourse.processing.org/t/algorithm-for-dividing-a-circle-providing-labels-for-only-some-of-the-divisions/25138

int maxNumeral = 12; // the highest numeral on the dial
int divisions = 12; // number of parts to divide the dial into
int numeral = maxNumeral; // starting numeral

for (int i = 0; i < maxNumeral; i+= maxNumeral/divisions) 
  {
  if (i == 0)
    println(maxNumeral);
  else
    println(i);
  }

```

---

<div class="post-metadata">

**Author:** ![ddownn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ddownn/32/2731_2.png) [@ddownn](https://discourse.processing.org/u/ddownn)\
**Post date:** [November 3, 2020, 6:45pm UTC](https://discourse.processing.org/t/algorithm-for-dividing-a-circle-providing-labels-for-only-some-of-the-divisions/25138/5 "2020-11-03T18:45:26Z")

</div>

No… just the number generation part
