Skip to content

IntersectionLineTriangle may fail near triangle edges due to floating-point precision #245

@rainLaien

Description

@rainLaien

Is this a known limitation of the current intersection algorithm in VCGlib? Could it be caused by floating-point precision issues (e.g., epsilon thresholds)? And is there a recommended way to handle these edge cases robustly?To improve robustness, I suggest using a small epsilon tolerance when evaluating barycentric bounds, and optionally clamping u and v to the [0,1] range to handle near-edge cases more gracefully. For example:

if (v < -EPSIL || u + v > T(1.0) + EPSIL) return false;
if (u < 0) u = 0;
if (u > 1) u = 1;
if (v < 0) v = 0;
if (v > 1) v = 1;
This helps mitigate failures in situations where the ray should conceptually intersect the triangle, but fails due to minor numerical inaccuracies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions