你能准确解释代码在做什么吗?
从函数名称,这是我的猜测:你有一个三角形棱镜阵列(“当前”),你正在检查这些点(xCoor,yCoor,zCoor)中的哪一个落入。
它只能落入一个,因为它们不重叠。
问题是如何确定哪一个是相关的。
显而易见的问题是“三角形是否以任何有意义的方式排列?”
举一个简单的例子,其中“当前”只是一个大小相等(每边S单位)立方体的阵列,它们被安排在一个10 * 10 * 8的棱镜中。
找出一个点所在的立方体是微不足道的:(xCoor / S,yCoor / S,zCoor / S)处的立方体是正确的。
然后你根本不需要循环。
三角形更难,但不是更难。
如果三角形的大小不一样,或者排列得不那么整齐,那么你可能会使用类似的东西。
存储一个单独的立方体贴图,并为每个立方体存储每个与该立方体相交的三角形棱镜(如果您知道棱镜的顶点,这很容易)。
这需要更多的内存,但是(如上所述)找出一个点所在的立方体是微不足道的,一旦你知道你只需要检查与该立方体相交的棱镜。
以上来自于谷歌翻译
以下为原文
Can you explain exactly what the code is doing? From the function names, here's my guess: you've got an array of triangular prisms ("current"), and you're checking which one of these a point (xCoor, yCoor, zCoor) falls into. It can only fall into one because they don't overlap. The question is how to determine which one is relevant.
The obvious question is "are the triangles arranged in any meaningful way?" Take a simplified example where "current" is just an array of equally-sized (S units per side) cubes and they're arranged in a 10*10*8 prism. Finding out which cube a point is in is trivial: the cube at (xCoor/S, yCoor/S, zCoor/S) is the correct one. Then you don't need the loop at all. It's harder for triangles, but not much harder.
If the triangles are not all the same size, or not arranged so neatly, you could potentially use something similar. Store a separate map of cubes, and for each cube store every triangular prism that intersects that cube (which is easy if you know the prism's vertices). This takes a bit more memory, but (as above) it's trivial to find out which cube a point is in, and once you know that you only have to check for prisms that intersect that cube.
你能准确解释代码在做什么吗?
从函数名称,这是我的猜测:你有一个三角形棱镜阵列(“当前”),你正在检查这些点(xCoor,yCoor,zCoor)中的哪一个落入。
它只能落入一个,因为它们不重叠。
问题是如何确定哪一个是相关的。
显而易见的问题是“三角形是否以任何有意义的方式排列?”
举一个简单的例子,其中“当前”只是一个大小相等(每边S单位)立方体的阵列,它们被安排在一个10 * 10 * 8的棱镜中。
找出一个点所在的立方体是微不足道的:(xCoor / S,yCoor / S,zCoor / S)处的立方体是正确的。
然后你根本不需要循环。
三角形更难,但不是更难。
如果三角形的大小不一样,或者排列得不那么整齐,那么你可能会使用类似的东西。
存储一个单独的立方体贴图,并为每个立方体存储每个与该立方体相交的三角形棱镜(如果您知道棱镜的顶点,这很容易)。
这需要更多的内存,但是(如上所述)找出一个点所在的立方体是微不足道的,一旦你知道你只需要检查与该立方体相交的棱镜。
以上来自于谷歌翻译
以下为原文
Can you explain exactly what the code is doing? From the function names, here's my guess: you've got an array of triangular prisms ("current"), and you're checking which one of these a point (xCoor, yCoor, zCoor) falls into. It can only fall into one because they don't overlap. The question is how to determine which one is relevant.
The obvious question is "are the triangles arranged in any meaningful way?" Take a simplified example where "current" is just an array of equally-sized (S units per side) cubes and they're arranged in a 10*10*8 prism. Finding out which cube a point is in is trivial: the cube at (xCoor/S, yCoor/S, zCoor/S) is the correct one. Then you don't need the loop at all. It's harder for triangles, but not much harder.
If the triangles are not all the same size, or not arranged so neatly, you could potentially use something similar. Store a separate map of cubes, and for each cube store every triangular prism that intersects that cube (which is easy if you know the prism's vertices). This takes a bit more memory, but (as above) it's trivial to find out which cube a point is in, and once you know that you only have to check for prisms that intersect that cube.
举报