spectrum is online!

master
Nova deViator 2015-09-11 17:35:11 +02:00
parent e6c5fe56c5
commit 0893176c02
2 changed files with 16 additions and 44 deletions

View File

@ -109,7 +109,7 @@ void setup() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
println("~~~ getting and processing lines data ...");
//siLinesData = new ArrayList<FloatList>();
siLinesData = getLinesData(); // function, returns an ArrayList
//printArray(siLinesData);
// ----------------------------------------------------------------------
@ -172,9 +172,19 @@ void draw() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// SCENENGINES / / / / / / / / / / / / / / / / / / / / / / / / / / |
// drawSpectrum
drawSpectrum(boolean(1),
siLinesData);
// draw spheress```````````````````````````````````````````````````|
drawSpheres(boolean(0)

View File

@ -12,6 +12,7 @@
ArrayList<FloatList> getLinesData() {
String[] siLinesData;
float[][] colors = { // these are taken from http://astro.u-strasbg.fr/~koppen/discharge/discharge.html
{ 3800.0, 0, 0, 0},
{ 4000.0, 150, 0, 150},
@ -24,27 +25,23 @@ ArrayList<FloatList> getLinesData() {
{ 7000.0, 80, 0, 0},
{ 7300.0, 0, 0, 0} };
String[] siLinesData;
int threshold = 400;
siLinesData = loadStrings(dataPath(sketchPath + "/silicon_lines.txt"));
ArrayList<FloatList> siLinesList = new ArrayList<FloatList>();
for (String lineData : siLinesData ) {
String[] datatemp = split(lineData, " ");
FloatList data_x;
data_x = new FloatList();
// clean up from that messy split
for (int i = 0; i < datatemp.length; i++) {
if (!datatemp[i].equals("")) { // if not empty (spaces):
data_x.append(float(datatemp[i]));
}
}
// process data - add rgb values
//println(data_x.get(0));
// iterate through colors and find RGB values for each line
float wavelength = data_x.get(0);
for (int i = 0; i < colors.length; i++){
float thisboundary = colors[i][0];
@ -57,49 +54,14 @@ ArrayList<FloatList> getLinesData() {
* (wavelength - colors[i][0]) ));
int blue = round(colors[i][3] + ( ( (colors[i+1][3] - colors[i][3]) / (colors[i+1][0] - colors[i][0]) )
* (wavelength - colors[i][0]) ));
// add them to the array
data_x.append(red);
data_x.append(green);
data_x.append(blue);
}
}
}
printArray(data_x);
siLinesList.add(data_x);
}
// for(int i = 0; i < siLinesList.size(); i ++) {
// //println(siLinesList.get(i).get(0));
// float wavelength = siLinesList.get(i).get(0);
// float intensity = siLinesList.get(i).get(1);
// if(intensity > threshold && wavelength < 6741 && wavelength > 3950) {
// // (item[1].asInt > threshold) && (item[0].asInt < 6741) && (item[0].asInt > 3950), {
// println(wavelength + " " + intensity);
// }
// }
//printArray(siLinesList);
return siLinesList;
}