0

Hi all,

I'm trying to create code which manipulates data within a vector. The vector contains floating points which store consecutive 3D values. For example element 1 stores object 1 x coords, element 2 - object 1 y coords, element 3 - object 1 z coords, element 4 object 2 x coords etc.

My problem, is I am trying to update the vector by replacing the values for the 3rd object x,y and z with the second objects, and then putting in new data for the first.

void shuffleArray()
{
	int a = 4;
	for (int c = 0; c < bodyPos.size()-3; c++) {
		bodyPos[a] = bodyPos[c];
		a++;
	}
}

This however won't work as it is only ending up with the first 3 elements.

Thanks,

Gareth

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Fbody
1

First, I'd like to ask why you don't have a vector of 3-D Points with each point containing its own x, y, and z coordinates.

I think you would find solving your problem substantially easier if you did.

If you choose to keep it the way you have it, I would suggest you look into the vector::insert() member function.

Edited by Fbody: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.