I have a vector 3 (x,y,z) 1D dynamic array full of vertex positions.
How would I return the y value at a given x and z coordinate?
Edit:: Sorry about the lack of detail.
I am using c++, compiling in Visual Studio 2008.
The vector is a vector class storing 3 float values defining an x, y and z variable, it is used for position.
It’s like Vector3 *array;
array = new Vector3[100];
Lots of positional values are added to the array.
When you access a member of the array for a specific value it’s like
array[0].y
But I want to find a the y value that corresponds to a specific x and z
like
GetY(float x, float z)
…
return y;
I suppose you have something like
Then, to get what you want, you’ll need to iterate over the array.
Edit: On your comment:
Though a problem that I forgot is the inaccuracy of
floats, so maybe you get problems with the map. Comment back if you do. 🙂Edit:
Added a more safe version, employing a
float_wrapper.