Since each row is a 3D point and so will definitely have 3 elements, an std::vector
isn't an appropriate type. I would perhaps use a std::array<float, 3>
or a struct
with members x
, y
, and z
for the inner type.
It seems that you don't actually want 1000 points in your vector. Maybe you're doing it to avoid reallocations later on? In that case, you should use Vector.reserve(1000);
. This will reserve memory for the points without actually adding them. Then you can add your points using emplace_back
, push_back
or any other mechanism.
Then, to get an iterator to the last point in the vector, you can do either std::end(Vector) - 1
or Vector.end() - 1
. If you had kept it as you had it, where there were always 1000 points in the vector, this would have given you an iterator to the 1000th point (even if you hadn't assigned any useful values to it yet).