|
From: Maria L. <li...@us...> - 2013-01-29 22:55:35
|
Hello, I tested the following code on my Mac laptop and our production Linux server both running matplotlib V1.0.1. Both machines observe the same output from the code, so I was wondering if somebody is aware of the problem or if it's some undocumented feature of "pnpoly()" function from matplotlib.nxutils? I use matplotlib.nxutils.pnpoly() function from matplotlib to determine if point belongs to the polygon. The following code: >>> import numpy as np >>> import matplotlib.nxutils as nx >>> coords = np.array([[4.0, 1.0], [4.0, 4.0], [5.0, 5.0], [6.0, 4.0], [5.0, 0.0]]) >>> nx.pnpoly(4.0, 1.0, coords) 1 >>> nx.pnpoly(4.0, 4.0, coords) 1 >>> nx.pnpoly(5.0, 5.0, coords) 0 >>> nx.pnpoly(6.0, 4.0, coords) 0 >>> nx.pnpoly(5.0, 0.0, coords) 0 The question is why first two vertexes are considered to be inside of defined polygon, and last 3 vertexes are not? My guess, it's treating the polygon as a semi-open set, and I wonder if it can be changed to make all vertexes inclusive? Any help would be greatly appreciated. Many thanks, Masha -------------------- li...@us... |