@@ -4754,20 +4754,21 @@ void TGraphPainter::PaintPolyLineHatches(TGraph *theGraph, Int_t n, const Double
47544754 Double_t xc, yc, c1, b1, c2, b2;
47554755 Bool_t cross = kFALSE ;
47564756 Int_t nf2 = nf;
4757+ const Double_t eps = 1e-12 ; // float precision
47574758 for (i=nf2; i>0 ; i--) {
47584759 for (j=i-1 ; j>0 ; j--) {
4759- if (xt[i-1 ]== xt[i] || xt[j-1 ]== xt[j]) continue ;
4760+ if (TMath::Abs ( xt[i-1 ]- xt[i]) < eps || TMath::Abs ( xt[j-1 ]- xt[j]) < eps ) continue ;
47604761 c1 = (yt[i-1 ]-yt[i])/(xt[i-1 ]-xt[i]);
47614762 b1 = yt[i]-c1*xt[i];
47624763 c2 = (yt[j-1 ]-yt[j])/(xt[j-1 ]-xt[j]);
47634764 b2 = yt[j]-c2*xt[j];
4764- if (c1 != c2) {
4765+ if (TMath::Abs ( c1 - c2) > eps ) {
47654766 xc = (b2-b1)/(c1-c2);
47664767 yc = c1*xc+b1;
4767- if (xc>TMath::Min (xt[i],xt[i-1 ]) && xc<TMath::Max (xt[i],xt[i-1 ]) &&
4768- xc>TMath::Min (xt[j],xt[j-1 ]) && xc<TMath::Max (xt[j],xt[j-1 ]) &&
4769- yc>TMath::Min (yt[i],yt[i-1 ]) && yc<TMath::Max (yt[i],yt[i-1 ]) &&
4770- yc>TMath::Min (yt[j],yt[j-1 ]) && yc<TMath::Max (yt[j],yt[j-1 ])) {
4768+ if (xc>TMath::Min (xt[i],xt[i-1 ])+eps && xc<TMath::Max (xt[i],xt[i-1 ])-eps &&
4769+ xc>TMath::Min (xt[j],xt[j-1 ])+eps && xc<TMath::Max (xt[j],xt[j-1 ])-eps &&
4770+ yc>TMath::Min (yt[i],yt[i-1 ])+eps && yc<TMath::Max (yt[i],yt[i-1 ])-eps &&
4771+ yc>TMath::Min (yt[j],yt[j-1 ])+eps && yc<TMath::Max (yt[j],yt[j-1 ])-eps ) {
47714772 nf++; xf[nf] = xt[i]; yf[nf] = yt[i];
47724773 nf++; xf[nf] = xc ; yf[nf] = yc;
47734774 i = j;
0 commit comments