diff --git a/hyper.h b/hyper.h index 50055c11..a38155c6 100644 --- a/hyper.h +++ b/hyper.h @@ -4556,6 +4556,8 @@ extern int cells_drawn; void menuitem_sightrange(char c = 'r'); +bool invalid_point(const hyperpoint h); +bool invalid_point(const transmatrix T); bool in_smart_range(const transmatrix& T); void curvepoint(const hyperpoint& H1); diff --git a/hypgraph.cpp b/hypgraph.cpp index c00a26b0..fa7a2914 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -684,8 +684,16 @@ transmatrix applyspin(const heptspin& hs, const transmatrix& V) { return hs.spin ? V * spin(hs.spin*2*M_PI/S7) : V; } +bool invalid_point(const hyperpoint h) { + return std::isnan(h[2]) || h[2] > 1e8 || std::isinf(h[2]); + } + +bool invalid_point(const transmatrix T) { + return std::isnan(T[2][2]) || T[2][2] > 1e8 || std::isinf(T[2][2]); + } + bool in_smart_range(const transmatrix& T) { - if(std::isnan(T[2][2]) || std::isinf(T[2][2]) || T[2][2] > 1e8) return false; + if(invalid_point(T)) return false; hyperpoint h1, h2, h3; applymodel(tC0(T), h1); if(std::isnan(h1[0]) || std::isnan(h1[1])) return false; diff --git a/polygons.cpp b/polygons.cpp index 08966c42..2b7250e3 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -2789,6 +2789,7 @@ void getcoord0(const hyperpoint& h, int& xc, int &yc, int &sc) { } void queuechr(const hyperpoint& h, int size, char chr, color_t col, int frame) { + if(invalid_point(h)) return; int xc, yc, sc; getcoord0(h, xc, yc, sc); queuechr(xc, yc, sc, size, chr, col, frame); } @@ -2798,16 +2799,19 @@ ld scale_in_pixels(const transmatrix& V) { } void queuechr(const transmatrix& V, double size, char chr, color_t col, int frame) { + if(invalid_point(V)) return; int xc, yc, sc; getcoord0(tC0(V), xc, yc, sc); queuechr(xc, yc, sc, scale_in_pixels(V) * size, chr, col, frame); } void queuestr(const hyperpoint& h, int size, const string& chr, color_t col, int frame) { + if(invalid_point(h)) return; int xc, yc, sc; getcoord0(h, xc, yc, sc); queuestr(xc, yc, sc, size, chr, col, frame); } void queuestr(const transmatrix& V, double size, const string& chr, color_t col, int frame, int align) { + if(invalid_point(V)) return; int xc, yc, sc; getcoord0(tC0(V), xc, yc, sc); // int xs, ys, ss; getcoord0(V * xpush0(.01), xs, ys, ss); @@ -2815,6 +2819,7 @@ void queuestr(const transmatrix& V, double size, const string& chr, color_t col, } void queuecircle(const transmatrix& V, double size, color_t col) { + if(invalid_point(V)) return; int xc, yc, sc; getcoord0(tC0(V), xc, yc, sc); int xs, ys, ss; getcoord0(V * xpush0(.01), xs, ys, ss); queuecircle(xc, yc, scale_in_pixels(V) * size, col);