Taking a slice of a two dimensional array

  • Context: Undergrad 
  • Thread starter Thread starter jing2178
  • Start date Start date
  • Tags Tags
    Array
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 2K views
jing2178
Messages
41
Reaction score
2
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.
 
Mathematics news on Phys.org
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.