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

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

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++;
}

Hi,

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

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 :

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
1 Like

Do you mean circle in a graphical sense?

Then also look website | tutorials | trigonometry please

Chrisir

Hello,

This came to mind:

//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);
  }
1 Like

No… just the number generation part

1 Like