开发者

2 dimensional array, calculating maximum value

I'm trying to get the maximum value in a line in an 2d array. For example is this greyscale image. For 开发者_JAVA技巧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.

2 dimensional array, calculating maximum value


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜