Traverse matrix in a direction specified by azimuth.
So I have a 2D matrix and an azimuth. What I want to do is traverse the matrix in that direction. From that azimuth I can derive a line equation.
Now I want to traverse the matrix in that direction of line. So in this case the 1st block I want to read info from is market as 1 then 2 and so on. (the values in the matrix right now are just to represent the order in which they are accessed)
Let’s say if the line derived from azimuth goes as shown in the figure below then the matrix should be traverse from left to right.
If the problem is not clear please ask any question and I will explain further. Thanks for your time.
Label cell in row i
column j
by i * sin(a) + j * cos(a)
. Then traverse in ascending order of these labels.
Assuming in your first example a
= 45° and in the second a
= 0°.
So for your first example, sin(a) = cos(a) = sqrt(0.5). The calculated labels are the values in your figure multiplied by sqrt(2).
For your second example, sin(a) = 0; cos(a) = 1 and you get the same values as in your figure.