Hi. I have this .txt file, exported from grasshopper. I am trying to use PVectore to split data in txt file and make a spiderweb from that, but I see error "array index out of bounds:1" in line 26. Anybody knows what is wrong with this code?
This is the code:
import peasy.*;
PVector GHpoints[] = new PVector[100];
PeasyCam cam;
PVector[] jumpersB;
void setup() {
size (600,600,P3D);
cam = new PeasyCam(this, 100);
cam.setMinimumDistance(5);
cam.setMaximumDistance(20);
smooth ();
frameRate(100);
}
void draw(){
background (255);
import_GH();
spiderWeb();
}
void import_GH(){
String GH_PT[]=loadStrings("GH_PT.txt");
for (int x=GH_PT.length-1; x>=0; x--){
float point[] = float(split(GH_PT[x], ' '));
PVector Temp_PT = new PVector(point[0], point[1], point[2]);
GHpoints[x] = Temp_PT;
}}
void spiderWeb(){
for (int i=0; i<GHpoints.length-1; i++){
for (int b=0; b<GHpoints.length-1; b++){
if( jumpersB[i] != null){
if( jumpersB[b] != null){
PVector locA = jumpersB[i]; PVector locB = jumpersB[b];
float distance = PVector.dist(locA, locB);
if ((distance > 0) && (distance < 3)) {
stroke(100, 110);
strokeWeight(1);
line(locA.x, locA.y, locA.z, locB.x, locB.y, locB.z);
}}}}}}