|
From: Andres L. <and...@gm...> - 2014-02-24 09:20:08
|
Hi It has been reported in http://matplotlib.1069221.n5.nabble.com/How-to-properly-use-path-Path-contains-point-td40718.htmlbut I do not see anything has happened after this. Following code illustrates the problem, when polygon defined in one direction, I can check if point is inside it, if other direction, I can not. from matplotlib.patches import Polygon poly1=Polygon([[0.,0.],[1.,0.],[1.,1.],[0.,1.]],facecolor='none') print(poly1.contains_point([0.5,0.5])) poly2=Polygon([[0.,0.],[0.,1.],[1.,1.],[1.,0.]],facecolor='none') print(poly2.contains_point([0.5,0.5])) print(poly2.contains_point([-0.5,-0.5])) I do not see an obvious reason why polygons should be defined in one direction only. I have tried the code with several versions of matplotlib, newest is 1.3.1 with numpy 1.8 and python 3.2.3 and all newer versions do not work as I would accept them. Only the oldest version, python2.6.6 with matplotlib 0.99.1.1 gives me correct answer. I have digged in the source code and ended up in file _path.cpp where the function point_in_path_impl seems to do the actual job, but understanding it completely seems to take more time than I have at the moment. Any feedback appreciated. Andres |