I stumbled upon a problem a few times. It’s either this or error: index: 0 size: 0
. Why is this happening. I am relatively new to this but I can’t do anything. It sometimes fixes on itself and at other times it just doesn’t.
ArrayList<Float> x = new ArrayList<Float>();
ArrayList<Float> y = new ArrayList<Float>();
ArrayList<Float> a = new ArrayList<Float>();
ArrayList<Float> px = new ArrayList<Float>();
ArrayList<Float> py = new ArrayList<Float>();
ArrayList<Float> pa = new ArrayList<Float>();
int n = 3, it = 0;
float l = 100, ba = -PI/2, spin = PI/3;
float spn[] = new float[3];
void setup() {
size(600, 600);
px.add(300);
py.add(500);
println(px.size());
for(int i = 0; i < n; i++) {
spn[i] = map(i,0,n-1,-spin/2,spin/2);
}
printArray(spn);
}
void draw() {
background(0);
stroke(255);
for(int i = 0; i < px.size(); i++) {
for(int j = 0; j < n; j++) {
line(px.get(0) + l*cos(spn[j]+ba), py.get(0) + l*sin(spn[j]+ba), px.get(0),py.get(0));
}
}
}