We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello Everybody!
I have a sketch with a Two-Dimensional PVector Array (with 5 arrays of 2 PVectors each). When assigning values to each PVector using mouse clicks, I print each array of 2 PVectors to the console, followed by a comma.
What I get after running the sketch is this:
[ 91.0, 399.0, 0.0 ] [ 82.0, 323.0, 0.0 ], [ 81.0, 271.0, 0.0 ] [ 87.0, 206.0, 0.0 ], [ 101.0, 146.0, 0.0 ] [ 134.0, 100.0, 0.0 ], [ 193.0, 91.0, 0.0 ] [ 258.0, 106.0, 0.0 ], [ 298.0, 168.0, 0.0 ] [ 331.0, 271.0, 0.0 ]
Now, what I want to do is use these values to create another two-dimensional array in a different sketch.
I tried using this code, but it doesn't seem to work:
PVector [][] people = {{[130.0, 372.0, 0.0], [132.0, 340.0, 0.0 ]}, {[ 131.0, 282.0, 0.0 ], [ 124.0, 240.0, 0.0 ]}, {[ 118.0, 210.0, 0.0 ], [ 114.0, 171.0, 0.0 ]}, {[ 119.0, 135.0, 0.0 ], [ 143.0, 112.0, 0.0 ]}, {[ 171.0, 105.0, 0.0 ], [ 210.0, 117.0, 0.0]}}
How can I use the values printed in the console to define the same 2d array of PVector's in a different sketch?
Thanks!!!
Answers
[130.0, 372.0, 0.0] and such are merely a String representation of a PVector's 3 fields -> x, y, z!
To get a real PVector, we gotta use keyword
new
to instantiate 1:Ah! A sample of how to save a List<PVector> as a file.
With some adaptations, might ease your work, who knows?
Great, thanks for the help!