Is it possible to make an array of vectors? I tried; PVector [ ] vtest = new PVector [20]; It lets me write it but gives me null messages when I execute.
1 Like
PVector[] vtest = new PVector[20];
void setup() {
for ( int i = 0; i < 20; i++ ) vtest[i] = new PVector(1,1,1);
printArray(vtest);
}
void draw() {}
works here
3 Likes
B/c it’s an array of object references, all of its indices are initialized w/ null
when it’s created:
Processing.org/reference/null.html
Thus we still need to assign a new
PVector object reference for each of its indices:
vtest[0] = new PVector();
3 Likes
Dear kll, You’re a genius!!! Thanx so much.
1 Like