I need to create a structure that allows me to define an x number of points (the number of points changes at run time) in a 3-D coordinate system. Each point has an x, y, and z value. So far I have a basic structure like this, but I need it to be able to have multiple points, each with their own values.
struct point {
int point_num;
double x;
double y;
double z;
};
Thanks!
If
point_numis a non-contiguous but unique identifier you could usestd::map<int, point>and remove the identifier from the struct. That way you get O(log(N)) lookup using the index.If
point_numvalues are unique and contiguous, usestd::vector<point>– again the id field is superfluous, as the location in the vector provides an indexing value for you.Read up a bit on STL, especially containers, before you go much further.