Thread: Grid Reference Problem

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    224

    Talking Grid Reference Problem

    Hi,

    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.

    thanks

  2. #2
    Registered User
    Join Date
    Nov 2006
    Posts
    224
    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?

    Any ideas?
    Thanks

  3. #3
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    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?
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  4. #4
    Registered User
    Join Date
    Nov 2006
    Posts
    224
    Quote Originally Posted by oogabooga View Post
    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.

    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

  5. #5
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    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.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  6. #6
    Registered User
    Join Date
    Nov 2006
    Posts
    224
    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

  7. #7
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    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?
    How big?


    Anyway, it sounds like you need to scale the x, y range to your grid range.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  8. #8
    Registered User
    Join Date
    Nov 2006
    Posts
    224
    Quote Originally Posted by oogabooga View Post
    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?
    How big?


    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.

    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?

  9. #9
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    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.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem passing by reference
    By Joe Bligh in forum C Programming
    Replies: 1
    Last Post: 01-16-2012, 10:08 AM
  2. problem in pass by reference
    By personal12 in forum C++ Programming
    Replies: 20
    Last Post: 09-25-2011, 11:28 AM
  3. Grid problem
    By talisix in forum C Programming
    Replies: 11
    Last Post: 10-14-2010, 02:17 AM
  4. Help with grid problem (dynamic programming)
    By scp89 in forum C Programming
    Replies: 15
    Last Post: 05-07-2009, 12:16 PM
  5. Problem with call by reference
    By zephyrcat in forum C Programming
    Replies: 2
    Last Post: 02-28-2008, 09:04 PM