Skip to content

Commit

Permalink
geometry: add paranoid check to lineseg_ellipse_intersect
Browse files Browse the repository at this point in the history
  • Loading branch information
Akaricchi committed May 8, 2024
1 parent fcc068f commit c8b017f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/util/geometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ bool lineseg_ellipse_intersect(LineSegment seg, Ellipse e) {
seg.b -= e.origin;

double ratio = re(e.axes) / im(e.axes);

if(UNLIKELY(ratio != ratio || !ratio)) {
// either axis is nan or 0?
assert(0 && "Bad ellipse");
return false;
}

cmplx rotation = cdir(-e.angle);
seg.a = cmul_finite(seg.a, rotation);
seg.b = cmul_finite(seg.b, rotation);
Expand Down

0 comments on commit c8b017f

Please sign in to comment.