I'm trying to get an algorithm for intersecting a "tube" (a 3D cubic Bézier curve extruded by a possibly-changing radius) with the following required properties:
- Computes intersections of ray and a 3D cubic Bézier curve. Must not become confused, as some numerical algorithms do, by secondary rays, which start from the surface of the curve (i.e. at a zero).
- Must support a varying radius along the curve (a linear function is fine). The radius may be zero in at-most one point.
- Hit point accuracy should be a function of floating-point precision or solver iterations. I.e., the geometry must be correct, fully volumetric.
- Some reasonable way of handling endpoints. I'd prefer spherical caps, but flat ones would be okay too. A choice would be nice.
I don't need the fastest-possible algorithm. The easiest reasonable algorithm is what I'm looking for.
Can someone help me find an ray + 3D-cubic-Bézier intersection algorithm satisfying the above? A paper link, a description, help pinning down references, etc.
I've had great difficulty with a literature search on this. Here are some of the (few) papers I found:
- "Ray Tracing for Curves Primitive". I implemented this, but the hit depth seems to be incorrect. I suspect this is because it assumes (erroneously) that the cross section of the curve will be circular, even if at an angle.
- "Exploiting Budan-Fourier and Vincent's Theorems for Ray Tracing 3D Bézier Curves". Seems over-complex, and doesn't seem to support varying radius. Looks like it has the same bad assumption, and code isn't available.
- "High-Quality Curve Rendering using Line Sampled Visibility". Quadratic curves only, rasterizer-based, unclear if meets other criteria.