algorithm - 找到射线和多边形之间交点的最快方法是什么?

标签 algorithm polygon raytracing

与问题所问的差不多。最好以伪代码形式回答并引用。正确答案应该重视速度而非简单性。

最佳答案

参见 Intersections of Rays, Segments, Planes and Triangles in 3D .您可以找到对多边形进行三角剖分的方法。

如果您真的需要射线/多边形相交,它位于 Real-Time Rendering 的 16.9| (第 2 版为 13.8)。

We first compute the intersection between the ray and [the plane of the ploygon] pie_p, which is easily done by replacing x by the ray.

 n_p DOT (o + td) + d_p = 0 <=> t = (-d_p - n_p DOT o) / (n_p DOT d)

If the denominator |n_p DOT d| < epsilon, where epsilon is very small number, then the ray is considered parallel to the polygon plane and no intersection occurs. Otherwise, the intersection point, p, of the ray and the polygon plane is computed: p = o + td. Thereafter, the problem of deciding whether p is inside the polygon is reduced from three to two dimentions...

有关详细信息,请参阅本书。

关于algorithm - 找到射线和多边形之间交点的最快方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/312328/

相关文章:

sql - 在 sql 数据库中使用实数进行显式排序

algorithm - 大型数据集的高效重新排序以最大化内存缓存效率

python - 在 Python 中高效地搜索字符串

c++ - 多向哈希表

c# - 使用 Clipper 合并不相交的多边形

java - 使用仿射变换旋转多边形

graphics - 光线追踪噪声

html - 在内联 svg 多边形中使用绝对和相对单位

javascript - 计算 4x4 矩阵的行列式 - (RayTracer 挑战) - Javascript

graphics - 处理路径追踪中的点光源和精确反射