Hello guys,
maybe someone can help me!
I built a struct like this:
struct{
char id;
ofVec3f rgb;
}Colors;
I create an array of struct with 255 elements:
Colors col[255];
populated the array of struct like this:
colors[0].id='\x00'; colors[0].rgb=ofVec3f(0,0,0);
colors[1].id='\x01'; colors[1].rgb=ofVec3f(0,0,0);
colors[2].id='\x02'; colors[2].rgb=ofVec3f(0,168,0);
colors[3].id='\x03'; colors[3].rgb=ofVec3f(0,168,0);
colors[4].id='\x04'; colors[4].rgb=ofVec3f(168,0,168);
colors[5].id='\x05'; colors[5].rgb=ofVec3f(168,0,168);
.....
I have a function that makes a loop on the array "struct Colors" and takes as input a ofVec3f:
char update(ofVec3f col) {
char id;
for (int i = 0; i < NUM_CHART_MAP; i++) {
ofVec3f rgb = colors[i].rgb;
if(rgb == col) { <------------------------------- this if() is wrong!
id=colors[i].id;
}
}
return id;
}
I want to find within the array of struct the value nearest to ofVec3f input.
excuse me English, I hope I explained.
I wish you happy holidays
Dario Image may be NSFW.
Clik here to view.