hi,

I am wondering if you can give me some ideas about below:

I've a program which uses 3 dimention cartesian co-ordinate system, I've written a program which generate input files for that program based on the 3D co-ordinates. However one thing that I dont get hold of is how to cover the 3D grid. For instance I've x=10, y=5, and z=3.14, I want to cover the grid in both directions i.e. left and right & up and down. One way is to use nested loops which will increment the existing x, y and z co-ordinate values. Can you please give me some ideas.

Yes, you need to clearly describe what you're trying to do.

A - are you storing the z value at each and every x,y coordinate? Such as, elevations at geographic positions. If so, you can really treat this as a 2D problem, where the data stored at each x,y cell is the third dimension value.

B - are you storing some value related to each x,y,z location? Such as, temperature at every 100 meter elevation above ground at each x,y position. This is truly a 3D data storage problem.

In most any problem where you want to iterate through an array (1D, 2D, 3D or more) you will generally use nested loops. Generally process by rows for most efficient memory access (by pages/levels, then by rows, then by columns for 3D)

Give us more detail, and preferably some sample code, and we'll give you more help.

so you want to essentially fill an area with some sort of shape?

if x=10, y=5 and z=3.14, you will only have a single pointer located at those coordinates. There is nothing to iterate through.

You will need a range of coordinates: for example, x = [5 - 10], y = [0 - 5] and z = [0 - 3.14].

Hi,
appologies for late reply as I was away for few days. Thank you all for you comments and feedback on my question. I am kind of in the learning process of all this so probably some of the stuff that guys have mentioned is too advance for me. However every help and idea is appreciated and welcomed. What I am trying to achieve is to cover a 3D grid similar to covering a 2D grid in which you increment x-axes by say a value 1 and then increcement y-axes to a number say 6. In the next round x is increment by 1 again (i.e. now at point2) and y is incremented to a number same as before i.e. 6. I am kind of confused in covering a 3D grid as its hard to visualise in reality however thats what I want to achieve by a c++ program. Also if anyone can explain how this 3D grid works and how is covered. Till now i've written a code which increments x & y by say a number 1 and then increment z to a selected point e.g. 6, please comment on this as well.

Thanks for all your help and feedback.

I am a little confused about your question. What are you trying to
do again?

Hi,
appologies for late reply as I was away for few days. Thank you all for you comments and feedback on my question. I am kind of in the learning process of all this so probably some of the stuff that guys have mentioned is too advance for me. However every help and idea is appreciated and welcomed. What I am trying to achieve is to cover a 3D grid similar to covering a 2D grid in which you increment x-axes by say a value 1 and then increcement y-axes to a number say 6. In the next round x is increment by 1 again (i.e. now at point2) and y is incremented to a number same as before i.e. 6. I am kind of confused in covering a 3D grid as its hard to visualise in reality however thats what I want to achieve by a c++ program. Also if anyone can explain how this 3D grid works and how is covered. Till now i've written a code which increments x & y by say a number 1 and then increment z to a selected point e.g. 6, please comment on this as well.

Thanks for all your help and feedback.

No, I am not using GUI its a program that uses 3D cartesian co-ordinate system it takes an input file with the cartesian co-ordinate values and generate outputs. However I am writing this code to generate input files for that program. But doing so I've to cover the 3D grid that is the requirement to generate input files in such a manner.

Look forward hearing from you soon.

This article has been dead for over six months. Start a new discussion instead.