Reputation: 8857
I'm trying to get the maximum value in a line in an 2d array. For example is this greyscale image. For me it's no problem to calculate the horizontal and vertical maximum grey value.
However, I don't have a clue how to calculate an angled line (green line) from this 2d array.
Anyone can help me out with this.
Upvotes: 0
Views: 322
Reputation: 101231
Do you know the angle of the line?
You can use the sinus and cosinus functions to calculate the x and y values of each point.
var x = Math.Cos(angle) * length
var y = Math.Sin(angle) * length
Where you increase the length each time. You will have to round the x and y values because they won't be integers.
You then use the x and y values as indices for the 2 dimensional arrays
Upvotes: 1