spectrum is online!
parent
e6c5fe56c5
commit
0893176c02
|
@ -109,7 +109,7 @@ void setup() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
println("~~~ getting and processing lines data ...");
|
println("~~~ getting and processing lines data ...");
|
||||||
//siLinesData = new ArrayList<FloatList>();
|
//siLinesData = new ArrayList<FloatList>();
|
||||||
siLinesData = getLinesData(); // function, returns an ArrayList
|
siLinesData = getLinesData(); // function, returns an ArrayList
|
||||||
|
//printArray(siLinesData);
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -174,8 +174,18 @@ void draw() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// SCENENGINES / / / / / / / / / / / / / / / / / / / / / / / / / / |
|
// SCENENGINES / / / / / / / / / / / / / / / / / / / / / / / / / / |
|
||||||
|
|
||||||
|
|
||||||
|
// drawSpectrum
|
||||||
|
drawSpectrum(boolean(1),
|
||||||
|
siLinesData);
|
||||||
|
|
||||||
|
|
||||||
// draw spheress```````````````````````````````````````````````````|
|
// draw spheress```````````````````````````````````````````````````|
|
||||||
drawSpheres(boolean(0)
|
drawSpheres(boolean(0)
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
ArrayList<FloatList> getLinesData() {
|
ArrayList<FloatList> getLinesData() {
|
||||||
|
|
||||||
|
String[] siLinesData;
|
||||||
float[][] colors = { // these are taken from http://astro.u-strasbg.fr/~koppen/discharge/discharge.html
|
float[][] colors = { // these are taken from http://astro.u-strasbg.fr/~koppen/discharge/discharge.html
|
||||||
{ 3800.0, 0, 0, 0},
|
{ 3800.0, 0, 0, 0},
|
||||||
{ 4000.0, 150, 0, 150},
|
{ 4000.0, 150, 0, 150},
|
||||||
|
@ -24,27 +25,23 @@ ArrayList<FloatList> getLinesData() {
|
||||||
{ 7000.0, 80, 0, 0},
|
{ 7000.0, 80, 0, 0},
|
||||||
{ 7300.0, 0, 0, 0} };
|
{ 7300.0, 0, 0, 0} };
|
||||||
|
|
||||||
String[] siLinesData;
|
|
||||||
int threshold = 400;
|
|
||||||
siLinesData = loadStrings(dataPath(sketchPath + "/silicon_lines.txt"));
|
siLinesData = loadStrings(dataPath(sketchPath + "/silicon_lines.txt"));
|
||||||
|
|
||||||
ArrayList<FloatList> siLinesList = new ArrayList<FloatList>();
|
ArrayList<FloatList> siLinesList = new ArrayList<FloatList>();
|
||||||
|
|
||||||
for (String lineData : siLinesData ) {
|
for (String lineData : siLinesData ) {
|
||||||
String[] datatemp = split(lineData, " ");
|
|
||||||
|
|
||||||
|
String[] datatemp = split(lineData, " ");
|
||||||
FloatList data_x;
|
FloatList data_x;
|
||||||
data_x = new FloatList();
|
data_x = new FloatList();
|
||||||
|
|
||||||
|
// clean up from that messy split
|
||||||
for (int i = 0; i < datatemp.length; i++) {
|
for (int i = 0; i < datatemp.length; i++) {
|
||||||
if (!datatemp[i].equals("")) { // if not empty (spaces):
|
if (!datatemp[i].equals("")) { // if not empty (spaces):
|
||||||
data_x.append(float(datatemp[i]));
|
data_x.append(float(datatemp[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// process data - add rgb values
|
// iterate through colors and find RGB values for each line
|
||||||
|
|
||||||
//println(data_x.get(0));
|
|
||||||
float wavelength = data_x.get(0);
|
float wavelength = data_x.get(0);
|
||||||
for (int i = 0; i < colors.length; i++){
|
for (int i = 0; i < colors.length; i++){
|
||||||
float thisboundary = colors[i][0];
|
float thisboundary = colors[i][0];
|
||||||
|
@ -57,49 +54,14 @@ ArrayList<FloatList> getLinesData() {
|
||||||
* (wavelength - colors[i][0]) ));
|
* (wavelength - colors[i][0]) ));
|
||||||
int blue = round(colors[i][3] + ( ( (colors[i+1][3] - colors[i][3]) / (colors[i+1][0] - 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]) ));
|
* (wavelength - colors[i][0]) ));
|
||||||
|
// add them to the array
|
||||||
data_x.append(red);
|
data_x.append(red);
|
||||||
data_x.append(green);
|
data_x.append(green);
|
||||||
data_x.append(blue);
|
data_x.append(blue);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printArray(data_x);
|
|
||||||
|
|
||||||
|
|
||||||
siLinesList.add(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;
|
return siLinesList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue