【发布时间】:2013-06-10 20:42:24
【问题描述】:
我想知道如何编写一个精确的算法来计算参数表面 f : R^2 --> R^3 和三角网格之间的相交表面的边界。
我想到了第一种方法:
nStepsU = 100
nStepsV = 100
tolerance=0.01 // pick some sensical value
intersectionVertices={}
for u from minU to maxU in nStepsU:
for v from minV to maxV in nStepsV:
for v in verticesInMesh:
if euclidean distance( f(u,v), v ) < tolerance:
add vertex v in a set
connect the vertices in intersectionVertices with a line strip
draw the vertices in intersectionVertices
该算法非常简单但速度较慢 (n^3),并且没有考虑到网格的地形是基于三角形的,因此输出点是网格的点,而不是利用曲面相交计算的点与三角形并在很大程度上取决于必须设置的公差。
有人有更好的主意,或者可以带我去一个合适的图书馆吗?
【问题讨论】:
-
您有关于表面的任何其他信息吗?你能有效地投影吗?你能有效地找到一个点在它的哪一边吗?
-
表面是螺旋面
x(r,theta) = r*cos(theta),y(r,theta) = theta,z(r,theta) = r*sin(theta)所以无法区分里面和外面 -
哦,对了。所以我的答案并不完全正确。但是您仍然可以从 (x,y,z) 确定 theta 和 r,并从中计算出有符号的距离。不过,我不清楚的是,您希望这有多精确?如果一个三角形在 y 方向上多次与曲面相交会怎样?
标签: opengl language-agnostic geometry collision-detection intersection