检测并找到相交射线与立方贝塞尔三角形 [英] Detect&find intersection ray vs. cubic bezier triangle

查看:97
本文介绍了检测并找到相交射线与立方贝塞尔三角形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编写模型编辑器的过程中,除了启用射线追踪之外,我还可以考虑一些操作,这些操作我想找到关于射线与三角形贝塞尔曲线的相交点的很好的近似值.

While writing a model editor, besides enabling raytracing I can think about couple of operations where I'd like to find an very good approximation about the intersection point between a ray and a triangular bezier patch.

如何执行此操作?我知道几种方法,但可能还有更好的方法.

How to do this? I know couple of ways but likely there's better ones.

确切的用例:我可能想使用一个贝塞尔三角形贴片作为参考表面,用鼠标绘制详细的形状.我可能也想从此类补丁中找出一个分裂点.

Exact use-cases: I might want to use one bezier triangle patch as a reference surface for drawing detailed shapes with mouse. I might too want to pinpoint a splitting-point from such patch.

如果有C源代码,我也希望看到.也许甚至用它代​​替滚动自己的代码.

If there's C source code for it, I might like to see that too. Perhaps even use it instead of rolling my own code.

推荐答案

我建议您实施

I'd suggest that you implement Triangular Bezier Clipping (PDF).

但是,另一种可能性是将您的三角形面片转换为张量积Bezier面片.这样做的好处是对张量积贝塞尔曲线提供了更多支持,因此您更有可能找到一些可以使用的代码.转换很简单:

However, another possibility would be to convert your triangular patch to a tensor-product Bezier patch. The advantage of doing this is that there is a lot more support for tensor-product Beziers so you're more likely to find some code that you can use. The conversion is simple:

  • 将三角形面片视为一系列n + 1行控制点(其中n是度)
    • 第一行具有1个控制点,每行比最后一行多1个控制点
    • View your triangular patch as a series of n+1 rows of control points (where n is the degree)
      • The first row has 1 control point, and each row has 1 more control point than the last
      • 每行现在将具有n + 1个控制点,形成n + 1 x n + 1个控制点网格

      对于仅找到相交点,这应该可以正常工作.但是,您的张量积补丁是退化的(一端有重合点),因此当您接近退化的拐角时,您可能会发现引入了一些数字问题.同样,映射回三角域可能会使诸如纹理映射之类的操作变得有些棘手.因此,如果您不介意任何实现,我建议您使用更直接的三角Bezier剪切".

      For just finding points of intersection this should work just fine. However, your tensor-product patch is degenerate (you have coincident points at one end) so you might find that you're introducing some numerical problems as you approach the degenerate corner. Also, mapping back to the triangular domain might make things like texture mapping a little extra tricky. So I'd suggest you use the more direct Triangular Bezier Clipping if you don't mind a bit of implementation.

      这篇关于检测并找到相交射线与立方贝塞尔三角形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆