4
$\begingroup$

Upd 09/08/25

Both bugs present in 14.3.0.0/Windows.

Bug 2:

Sometimes, WindingPolygon inverts the result.

w = 1.75; pts = Reverse@{{-3, -3}, {-w, -3}, {-w, 3}, {-3, 3}, {-3, w}, {3, w}, {3, 3}, {w, 3}, {w, -3}, {3, -3}, {3, -w}, {-3, -w}}; tstPts = .5 {{0, 0}, {-3 - w, -3 - w}, {3 + w, -3 - w}, {3 + w, 3 + w}, {-3 - w, 3 + w}}; WindingCount[Line@Append[pts, pts[[1]]], tstPts] Show[ Graphics@Line@Append[pts, pts[[1]]], Graphics@WindingPolygon[pts, "PositiveRule"], Graphics@{Red, PointSize[Large], Point@tstPts} ] 

This looks just as expected:

enter image description here

However, for w=1.25 (and for any w <=1.5), WindingPolygon inverts the result:

enter image description here

Notice that WindingCount is the same and correct in both cases.

Tested in WM 14.1 and 14.2 // Windows.

Is there a workaround?

Bug 1:

WindingPolygon over a self-intersection contour with intersecting collinear segments

Consider this self-intersecting polygon:

pts = {{0, -550}, {827, -550}, {1188, -188}, {800, 200}, {411, -188}, {772, -550}, {2150, -550}, {2150, 1150}, {150, 1150}}; Show[ Graphics@Line@Append[pts, pts[[1]]], MapThread[Callout, {pts, Range[9]}] // ListPlot ] 

enter image description here

Notice that segments 1-2 and 6-7 are collinear and intersecting.

Graphics@WindingPolygon[pts] produces a bug: enter image description here

Tested in 14.2, 14.1, 13.3.1 Windows 10 and 14.2 mac.

The expected result: enter image description here

Question: Is there a workaround?

$\endgroup$
4
  • 5
    $\begingroup$ Still present in 14.2 mac. If you ever so slightly disturb the points it will work: pts+=RandomReal[10^-12 {-1, 1}, {9, 2}] but it appears to be a bug. please report to Wolfram. $\endgroup$ Commented Feb 6 at 18:35
  • 1
    $\begingroup$ It is great to find and report bugs, but I don't see a question here. $\endgroup$ Commented May 14 at 19:30
  • $\begingroup$ @JasonB. There is now. Answers? $\endgroup$ Commented May 15 at 8:59
  • $\begingroup$ @SHuisman does not work if pts are translated by {8000,8000} or more. However, if pts are slightly rotated, the bug disappears. It only occurs on horisontal lines. $\endgroup$ Commented May 16 at 9:44

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.