Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Taking a slice of a two dimensional array

  1. Jan 23, 2013 #1
    The source of this question is an unanswered question at stackoverflow but I believe is more mathematical than computational.

    My question arising from this is.

    You have a two dimensional array of numbers, each element of the array is represented by a square box. The boxes arranged into a rectangle with element (i,j) represented by the box in position (i,j). A 1-dimensional slice of the array is formed by drawing a line across the boxes, choosing boxes based on the position of the line crossing them and a vector formed on the basis of the chosen boxes.

    This pdf file shows an issue arising following one attempt to do this.

    Are there already recognised ways of doing this?
    Are there better ways of doing this than the way I have tried?
    Can the question be stated in a more succinct way?

    Any help please.
     
  2. jcsd
  3. Jan 23, 2013 #2

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    All 3 methods are possible - and you could take alternating lower/upper pixel as well if "combined pixel" is not practical for some reason.
    To make things even more complicated: The cell right of 2 is not hit in the center - you could try to take that into account as well.

    Which method is best for you depends on the application.
     
  4. Jan 23, 2013 #3
  5. Jan 24, 2013 #4
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook