在二维阵列特殊polygonial for循环 [英] Special polygonial for loop in two dimensional array
问题描述
这是给你的计算机科学家有点棘手的问题。
比方说,我有100个由100个条目,编曲[I] [J]的二维数组/矩阵。其中i和j进入从0-99。
这可以被设想为点与对应于数据值中的每个点的正方形。
This is a bit tricky question for you computer scientists. Let's say that I have a two dimensional array/matrix of 100 by 100 entries, arr[i][j]. Where i and j goes from 0-99. This can be envisioned as a square of dots with each dot corresponding to a data value.
现在,如果我定义了一个4点多边形知道4点indicies:
是否有可能(有一个聪明的算法)来循环只有在矩阵那些条目位于4点多边形的内部?
即,在环圈的i的每一个值和j对应于值在改编由[i] [j]的即有趣(i和j是4点的聚内侧)
Now, If I define a 4 point polygon and know the indicies of the 4 points: Is it possible (is there an clever algorithm) to loop through only those entries in the matrix that lies inside of the 4-point polygon? That is, every value of i and j in the loop laps correspond to a value in arr[i][j] that is interesting (i and j is inside the 4-point poly).
这是清楚了吗?我明白,如果这是很难理解的。
Is this clear? I understand if it is difficult to understand.
此致
推荐答案
听起来相似三角形光栅化。
Sounds similar to triangle rasterization.
有一些文章/教程,你可以在它身上找到,比如这个:
There are a number of articles/tutorials you can find on it, such as this one:
http://joshbeam.com/articles/triangle_rasterization/
或本
http://sol.gfxile.net/tri/index.html
通过4点多刚将它分成2个三角形。
With a 4-point poly just split it into 2 triangles.
这篇关于在二维阵列特殊polygonial for循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!