1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
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


    User Avatar
    2017 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
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook