Grid Reference Problem
I need some ideas/advice on how to code the following:
I have two random numbers which are generated and are related to each other (representing x and y co-ordinate). These random numbers are generated within a specified range: (-range, +range).
I want to categorize these values in a (2-dimensional) grid. The grid size is not definite and so can be varied by the user would be in the order of 400 x 400. (e.g., think CCD detector). For each random number pair (x, y) I want to store a hit (a plus one) in the corresponding grid reference.
In the order of 500,000 related random numbers (x and y) are to be generated and the position recorded according to grid reference. So code needs to be fast.
any ideas/advice? much appreciated.
I suppose another way to do this would be afterwards.
In real time would be nice. However, post processing wouldn't be so bad.
i.e.) If I had ~500,000 x and y values between -range and + range. How could I collate them on a variable size grid of a * a?
500000 is not very much so your code does not have to be particularly fast.
What exactly is your project?
What does your code look like so far?
I am still thinking about the method. When i rush these seemingly simple tasks it often ends up with poor hard coding. I am still considering the best method.
Originally Posted by oogabooga
I think post processing is what I will do.
Gather the ~500,000 or so x, y data points comma separated in a text file and then try and spatialize them according to some grid I specify.
I would like to hear ideas from others on how they would do that? Just advice or general pseudo code would be great
But you haven't described exactly what you mean by "spatializing" them.
What's the relationship between the range of the input points and the grid size?
Give some examples.
So, the (x, y) data refers to a position in a circle.
I need to make the data meaningful. By that I want to know where these x,y points are situated on the circle, how they are distributed. In doing so, I am thinking of an imaginary grid overlaying the circle. The number of grid points is variable. But for a given grid, how many fall in grid reference (A,1), how many fall in (G, 5). ** using some arbitrary grid referencing
Are x and y integers?
What's their range?
Is the range variable?
I'm assuming the grid is integral.
What's the limits of it's ranges?
How small can it be?
Anyway, it sounds like you need to scale the x, y range to your grid range.
Thanks for your questions. Its helping me to properly form the problem.
Originally Posted by oogabooga
The range is variable. between -circle radius and + circle radius.
How do you mean integral?
I want the grid size to be variable. So for one run I may set it to 100 x 100. Another may be 400 x 400.
How would you set up the grid?
By "integral" I'm asking if the x, y values are just integers or whether they can have digits to the right of the decimal point.
For the grid it looks like you'll have to dynamically allocate a 2D array, presumably of ints or unsigned ints since you want to use it to store counts.