hello.
I try to create vector matrix of ofPoint.
Where is my mistake?
vector<ofPoint> coords;
vector <vector <ofPoint>> matrixCoords;
coords.resize(10);
for (int i = 0; i < 10; i ++) {
coords[i].x = i * 10;
coords[i].y = i * 20;
}
for (int i = 0; i < 5, i ++) {
matrixCoords.push_back(coords);
}
ofLog() << matrixCoords[1][1].x; // NotWork
for (int i = 0; i < 5; i ++) {
matrixCoords.push_back(coords);
}
Full working code with two typos fixed should work fine:
vector<ofPoint> coords;
vector <vector <ofPoint> > matrixCoords;
coords.resize(10);
for (int i = 0; i < 10; i ++) {
coords[i].x = i * 10;
coords[i].y = i * 20;
}
for (int i = 0; i < 5; i++) {
matrixCoords.push_back(coords);
}
ofLog() << matrixCoords[1][1].x; // Should work now and give you "10"