geometry: add paranoid check to lineseg_ellipse_intersect

This commit is contained in:
Andrei Alexeyev 2024-05-08 16:12:31 +02:00
parent fcc068f0e5
commit c8b017f974
No known key found for this signature in database
GPG key ID: 72D26128040B9690

View file

@ -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);