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

  • Context: High School 
  • Thread starter Thread starter sean123
  • Start date Start date
  • Tags Tags
    Algebra
Click For Summary
SUMMARY

This discussion focuses on assigning colors to crystals using a simple algebraic formula based on the variables noOfCrystals and noOfColours. The user provides examples where colors are assigned to crystals in groups, demonstrating the logic behind the color assignment. The formula presented by Sean utilizes the round down function to determine the color index based on the crystal number, effectively adapting to changes in the number of crystals and colors. This approach ensures a systematic method for color assignment that can be easily modified for different scenarios.

PREREQUISITES
  • Understanding of algebraic formulas and functions
  • Familiarity with programming concepts, particularly in conditional statements
  • Basic knowledge of arrays and indexing in programming
  • Experience with mathematical operations such as rounding
NEXT STEPS
  • Research how to implement conditional statements in your preferred programming language
  • Learn about array manipulation and indexing techniques
  • Explore mathematical functions such as floor and ceiling in programming
  • Investigate dynamic variable assignment based on user input
USEFUL FOR

Programmers, game developers, and anyone interested in algorithm design for color assignment in graphical applications.

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)]
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 23 ·
Replies
23
Views
2K
  • · Replies 22 ·
Replies
22
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 24 ·
Replies
24
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
Replies
6
Views
2K
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K