Vectors are a class within Java. Processing makes Java applets for you using an open source library of handy gubbinz that makes learning C style object orientated languages very easy for you. There's a whole host of hidden functions available
herePersonally I don't use Vectors, I use a method which involves something called a deep-copy. You make an empty array that's a bit longer (call it temp for example) and then deep-copy you old array into the new one. In that extra slot on the end you just put in the last bit of the old array again.
I read a post where it is said that the deep-copy method is faster than Vectors. Here's an example of some deep-copy methods you could adapt for your work. They're based on the
array transforming methods in the reference.
Code:
//2D vector path class (not to be confused with Java's "Vector") and methods
class Vec2{
float x,y;
Vec2(){}
Vec2(float x, float y){
this.x = x;
this.y = y;
}
}
//array functions
Vec2 [] addVec2(Vec2 [] vectors, Vec2 newVector) {
Vec2 [] temp = new Vec2[vectors.length + 1];
System.arraycopy(vectors, 0, temp, 0, vectors.length);
temp[vectors.length] = newVector;
return temp;
}
Vec2 [] concatVec2(Vec2 [] vectors, Vec2 [] addVectors) {
Vec2 [] temp = new Vec2[vectors.length + addVectors.length];
System.arraycopy(vectors, 0, temp, 0, vectors.length);
System.arraycopy(addVectors, 0, temp, vectors.length, addVectors.length);
return temp;
}
Vec2 [] subsetVec2(Vec2 [] vectors, int offset, int len) {
Vec2 [] temp = new Vec2[len];
System.arraycopy(vectors, offset, temp, 0, len);
return temp;
}
Usage would be along the lines of:
myPath = addVec2(myPath, newCoords);
Yes you have to make it all yourself in Processing. But at least you can have multi-dimensional arrays of anything and everything and don't have to dicker with that _root["clipName" + cantPutMovieClipInArraySoHeresANumberTackedOnTheEndOfAString].stuff() that's driving me up the wall in Flash right now.