简体   繁体   English

"相交线与二次贝塞尔三角形"

[英]Intersect Line vs Quadratic Bezier Triangle

I'm trying to find the intersection between a line segment and a quadratic bezier triangle for my OpenCL real time raytracer.我正在尝试为我的 OpenCL 实时光线追踪器找到线段和二次贝塞尔三角形之间的交点。

This question Detect&find intersection ray vs. cubic bezier triangle<\/a> talks about finding the collision point between a ray and a cubic bezier triangle and the main recomendations are to try subdivision, or tensor product bezier patches.这个问题Detect&find intersection ray vs.cubic bezier triangle<\/a>讨论了寻找射线和三次贝塞尔三角形之间的碰撞点,主要建议是尝试细分或张量积贝塞尔补丁。

I've read in a few places that when testing a line segment against a quadratic bezier triangle, that you just end up having to solve a quadratic equation, but I haven't found any information on what that equation actually is and am starting to wonder if it's true.我在一些地方读到过,在针对二次贝塞尔三角形测试线段时,您最终不得不求解二次方程,但我还没有找到任何关于该方程实际是什么的信息,并且开始想知道这是不是真的。 My attempts to find it also have come up short so far :P到目前为止,我试图找到它的尝试也失败了:P

Does anyone know if this is true or how to solve it besides using subdivision or tensor product bezier patches?除了使用细分或张量积贝塞尔补丁之外,有谁知道这是否属实或如何解决?

Here's the equation for a quadratic bezier triangle:这是二次贝塞尔三角形的方程:

AS^2 + 2*D S<\/em> T + 2*E S<\/em> U + B*T^2 + 2*F T<\/em> U + C*U^2 AS^2 + 2*D S<\/em> T + 2*E S<\/em> U + B*T^2 + 2*F T<\/em> U + C*U^2

Where S,T,U are the parameters to the triangle.其中 S,T,U 是三角形的参数。 You could replace U with (1-ST) since they are barycentric coordinates.您可以用 (1-ST) 替换 U,因为它们是重心坐标。

A,B,C are the corners of the triangle, and D,E,F are the control points along the edges. A,B,C 是三角形的角,D,E,F 是沿边的控制点。

Super stumped on this one!超级难倒这个!

"

Line segment has parametric equation P = P0+(P1-P0)*v=P0+d*v , where v is parameter [0..1] To find intersection with brute force, you have to solve system of three quadratic equations like 线段具有参数方程式P = P0+(P1-P0)*v=P0+d*v ,其中v是参数[0..1]要找到具有蛮力的交点,必须求解三个二次方程组,例如

x0+dx*v=AxS^2 + 2*Dx*S*T + 2*Ex*S*U + Bx*T^2 + 2*Fx*T*U + Cx*U^2

This system has 8 possible solutions, and intersection(s) exists only if resulted v,s,t lie in range 0..1 simultaneously. 该系统有8个可能的解,并且仅当结果v,s,t同时位于范围0..1中时才存在交集。 It's not easy to solve this system (possible approaches - Gröbner basis , numerical methods, and solution process might be numerically unstable). 解决这个系统并不容易(可能的方法-Gröbner基础 ,数值方法和求解过程在数值上可能不稳定)。 That is why subdivision method is sometimes recommended. 这就是为什么有时建议使用细分方法的原因。

when your bezier patch has more than 3 sides, ray-intersection is no longer analytic (even if the splines on the side are only quadratic) and a precise enough iterative approach is significantly slower.当你的贝塞尔面片有超过 3 条边时,光线交点不再是解析的(即使边上的样条线只是二次的),并且足够精确的迭代方法会明显变慢。 Bezier patches are pathetic in terms of performance due to inherent recursion, you may want to do FFT for fourier-patches instead.由于固有的递归,Bezier 补丁在性能方面是可悲的,您可能希望对傅立叶补丁进行 FFT。 Shadertoy.com [iq] has various "twisted cube intersection"s (that are not iterated by sphere-tracking==raymarching, which is efficient, but also causes MANY low-precision-cases-artifacts, where ever convergence of iteration is too slow). Shadertoy.com [iq] 有各种“扭曲的立方体交点”(不通过 sphere-tracking==raymarching 进行迭代,这是有效的,但也会导致许多低精度情况下的伪影,其中迭代的收敛太慢的)。

yes, triangular-bezierpatch intersections has only analytic quadratic complexity (with quadratic beziers on the borders), but it involves some pre-computation (unless it is already in barycentric coordinates), that significantly lower the resulting precision (barycentric adds 1 division globally, and sums up over all domains)是的,三角形-贝塞尔补丁交点只有解析二次复杂度(边界上有二次贝塞尔曲线),但它涉及一些预计算(除非它已经在重心坐标中),这会显着降低结果精度(重心在全球范围内增加 1 个除法,并总结所有领域)

This was solved (poorly, as in it has 1 error case and too low precision) on shadertoy in opengl in 2019: https:\/\/www.shadertoy.com\/view\/XsjSDt<\/a> and i optimized it slightly (fixed precision issues, added camera and culling): https:\/\/www.shadertoy.com\/view\/ttjSzw<\/a> + https:\/\/www.shadertoy.com\/view\/wlSyzd<\/a> also see, https:\/\/www.reddit.com\/r\/askmath\/comments\/sfn8mk\/analytic_intersection_ray\/<\/a>这在 2019 年的 opengl 中的 shadertoy 上得到了解决(很差,因为它有 1 个错误情况和太低的精度): https<\/a> :\/\/www.shadertoy.com\/view\/XsjSDt 我稍微优化了它(修复了精度问题,添加了相机和剔除): https<\/a> :\/\/www.shadertoy.com\/view\/ttjSzw + https:\/\/www.shadertoy.com\/view\/wlSyzd<\/a>另见, https:\/\/www.reddit.com\/r\/askmath\/comments\/ sfn8mk\/analytic_intersection_ray\/<\/a>

"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM