How can I assign colors to crystals based on a simple algebraic formula?

  • Level: High School 
  • Thread starter Thread starter sean123
  • Start date Start date
  • Tags Tags
    Algebra
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
1 reply · 3K views
sean123
Messages
2
Reaction score
0
Hi Everyone! I've been a member for a while, but I've been away...

It's good to be back though- I hope i find everyone well!

I have an algebra question for a program I'm writing. I'm looking for a simple algebraic formula which can cope with any changes to the noOfCrystals & noOfColours variables.

#### an example

noOfCrystals = 8
noOfColours = 4 [red, green, blue, black)

change Colours every 2 crystals

if (crystal ==1) or (crystal ==2) colour = red
if (crystal ==3) or (crystal ==4) colour = green
if (crystal ==5) or (crystal ==6) colour = blue
if (crystal ==7) or (crystal ==8) colour = black

#### another time it might read:

noOfCrystals = 9
noOfColours = 3 [red, green, blue)

change Colours every 3 crystals

if (crystal ==1) or (crystal ==2) or (crystal ==3) colour = red
if (crystal ==4) or (crystal ==5) or (crystal ==6) colour = green
if (crystal ==7) or (crystal ==8) or (crystal ==9) colour = blue

does this make sense? I am extremely grateful for any help!

Sean
 
Mathematics news on Phys.org
noOfCrystals = 8
noOfColours = 4
c[1] = red
c[2] = green
c[3] = blue
c[4] = black
colour = c[rounddown(crystal * noOfColours / noOfCrystals)]