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