Detect&find intersection ray vs. cubic bezier triangle

╄→гoц情女王★ 提交于 2019-12-04 14:53:30

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

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:

  • 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
  • Now, treat each row as a Bezier curve of the appropriate degree (degree 0 to degree n)
  • Degree elevate each row to degree n
    • Each row will now have n+1 control points, forming an n+1 by n+1 grid of control points
  • This grid of points, taken as a degree n by n Bezier patch, is an identical surface to your triangle

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.

I'm not familiar with triangular bezier patch, but if it can always be contained within a triangle then, if the ray intersects the triangle, it must intersect the curve inside it too.

If the above is true, then you can search the curve between the two vertices whose side intersects the ray for a point that is close enough to the ray. I guess you can do binary search on the curve parameter in this region to get that point.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!