From: <jd...@us...> - 2008-10-17 13:46:48
|
Revision: 6236 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6236&view=rev Author: jdh2358 Date: 2008-10-17 13:46:39 +0000 (Fri, 17 Oct 2008) Log Message: ----------- added nxutils api doc Modified Paths: -------------- trunk/matplotlib/doc/api/index.rst trunk/matplotlib/doc/faq/howto_faq.rst Added Paths: ----------- trunk/matplotlib/doc/api/nxutils.api Modified: trunk/matplotlib/doc/api/index.rst =================================================================== --- trunk/matplotlib/doc/api/index.rst 2008-10-17 13:08:33 UTC (rev 6235) +++ trunk/matplotlib/doc/api/index.rst 2008-10-17 13:46:39 UTC (rev 6236) @@ -22,6 +22,7 @@ collections_api.rst colorbar_api.rst colors_api.rst + nxutils_api.rst path_api.rst pyplot_api.rst index_backend_api.rst Added: trunk/matplotlib/doc/api/nxutils.api =================================================================== --- trunk/matplotlib/doc/api/nxutils.api (rev 0) +++ trunk/matplotlib/doc/api/nxutils.api 2008-10-17 13:46:39 UTC (rev 6236) @@ -0,0 +1,15 @@ +******************* +matplotlib nxutils +******************* + +The nxutils are numerical utilities written in C, mainly to support +computational gemoetry that is not in `numpy <http://numpy.scipy.org>`_. + + +:mod:`matplotlib.nxutils` +=========================== + +.. automodule:: matplotlib.nxutils + :members: + :undoc-members: + :show-inheritance: Modified: trunk/matplotlib/doc/faq/howto_faq.rst =================================================================== --- trunk/matplotlib/doc/faq/howto_faq.rst 2008-10-17 13:08:33 UTC (rev 6235) +++ trunk/matplotlib/doc/faq/howto_faq.rst 2008-10-17 13:46:39 UTC (rev 6236) @@ -289,3 +289,50 @@ fig.autofmt_xdate() plt.show() + +.. _point-in-poly: + +How do I test whether a point is inside a polygon? +================================================== + +The :mod:`matplotlib.nxutils` provides two high performance methods: +for a single point use :func:`~matplotlib.nxutils.pnpoly` and for an +array of points use :func:`~matplotlib.nxutils.points_inside_poly`. +For a discussion of the implementation see `pnpoly +<http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html>`_. + +.. sourcecode:: ipython + + In [25]: import numpy as np + + In [26]: import matplotlib.nxutils as nx + + In [27]: verts = np.array([ [0,0], [0, 1], [1, 1], [1,0]], float) + + In [28]: nx.pnpoly( 0.5, 0.5, verts) + Out[28]: 1 + + In [29]: nx.pnpoly( 0.5, 1.5, verts) + Out[29]: 0 + + In [30]: points = np.random.rand(10,2)*2 + + In [31]: points + Out[31]: + array([[ 1.03597426, 0.61029911], + [ 1.94061056, 0.65233947], + [ 1.08593748, 1.16010789], + [ 0.9255139 , 1.79098751], + [ 1.54564936, 1.15604046], + [ 1.71514397, 1.26147554], + [ 1.19133536, 0.56787764], + [ 0.40939549, 0.35190339], + [ 1.8944715 , 0.61785408], + [ 0.03128518, 0.48144145]]) + + In [32]: nx.points_inside_poly(points, verts) + Out[32]: array([False, False, False, False, False, False, False, True, False, True], dtype=bool) + +.. htmlonly:: + + For a complete example, see :ref:`_event_handling-lasso_demo`. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |