Random PVector
in
Programming Questions
•
2 years ago
Hi, I am new to Processing and am trying to randomly select a PVector form an arralist of PVectors (using data parsing; arraylist to cast the individual x,y,z components into PVector format). In void draw() thePVectors are displayed:
for(int i = 0; i < pointList.size(); ++i) {
pushMatrix();
PVector vec3D = (PVector) pointList.get(i);
translate(vec3D.x,vec3D.y,vec3D.z);
box(10);
popMatrix();
pushMatrix();
PVector vec3D = (PVector) pointList.get(i);
translate(vec3D.x,vec3D.y,vec3D.z);
box(10);
popMatrix();
How do I tell Pocessing to randomly select a PVector from this arraylist? Problem with random is that it returns a float function. Java Random() class doesn't seem to work with the arraylist. The best I can get to is:
int randVec = (int)random(pointList.size());
which selects the sequence number of the PVector in the list but doesn't cast the x,y,z components of the PVector. How do I go from here?
1