Title: Issue detecting paths intersection with Path.intersects_path · Issue #6076 · matplotlib/matplotlib · GitHub
Open Graph Title: Issue detecting paths intersection with Path.intersects_path · Issue #6076 · matplotlib/matplotlib
X Title: Issue detecting paths intersection with Path.intersects_path · Issue #6076 · matplotlib/matplotlib
Description: Short Description I think there may be a bug in the Path.intersects_path method, in path module: Signature: Path.intersects_path(self, other, filled=True) Docstring: Returns *True* if this path intersects another given path. *filled*, wh...
Open Graph Description: Short Description I think there may be a bug in the Path.intersects_path method, in path module: Signature: Path.intersects_path(self, other, filled=True) Docstring: Returns *True* if this path int...
X Description: Short Description I think there may be a bug in the Path.intersects_path method, in path module: Signature: Path.intersects_path(self, other, filled=True) Docstring: Returns *True* if this path int...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/6076
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Issue detecting paths intersection with Path.intersects_path","articleBody":"## Short Description\n\nI think there may be a bug in the `Path.intersects_path` method, in `path` module:\n\n``` python\nSignature: Path.intersects_path(self, other, filled=True)\nDocstring:\nReturns *True* if this path intersects another given path.\n\n*filled*, when True, treats the paths as if they were filled.\nThat is, if one path completely encloses the other,\n:meth:`intersects_path` will return True.\nFile: ~/anaconda/lib/python2.7/site-packages/matplotlib/path.py\nType: instancemethod\n```\n\nPlaying with it, I encountered **some cases where this method answers that the two paths are not intersecting, while after plotting them, they do** (see the example script and picture below). I still didn't have time to look into further (especially the C++ code that is wrapped by the method), but it seems to me that this behavior is not correct, is it?\n## Details\n- [X] Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)\n\nMatplotlib 1.5.1, with Python 2.7.11 (and IPython 4.0.1), on Linux (CentOS 7 or Manjaro)\n- [X] How did you install Matplotlib and Python (pip, anaconda, from source ...)\n\nAnaconda 2.4.0 (64-bit)\n- [X] If possible please supply a [Short, Self Contained, Correct, Example](http://sscce.org/)\n that demonstrates the issue i.e a small piece of code which reproduces the issue\n and can be run with out any other (or as few as possible) external dependencies.\n\n``` python\n# -*- coding: utf-8 -*-\nimport matplotlib.pyplot as plt\nfrom matplotlib.patches import PathPatch\nfrom matplotlib.path import Path\n\ncubic_bezier_codes = [Path.MOVETO, Path.CURVE4, Path.CURVE4, Path.CURVE4]\n\ndef plot_ctrls(verts, ax, label='',\n ls='--', marker='o', ms=5, lw=1, alpha=0.6, color='Gray'):\n \"\"\"Plot the control points of a Bezier curve (debugging purpose)\n \"\"\"\n ax.plot(*zip(*verts), ls=ls, lw=lw, color=color, ms=ms, marker=marker,\n alpha=alpha, label=label)\n return ax\n\n# For your viewing pleasure when plotting\ndetection_color = {True: \"OliveDrab\", False: \"Crimson\"}\n\nif __name__ == \"__main__\":\n plt.ion()\n\n # A dummy path to play with\n verts_1 = [(0.5, 0.01), (0.21, 0.99), (0.99, 0.8), (0.99, 0.99)]\n path_1 = Path(verts_1, cubic_bezier_codes)\n\n # A path that does intersect with path_1 but for which the ad-hoc test\n # method fails\n verts_2a = [(0.5, 0.8), (0.5, 0.7), (0.6, 0.75), (0.56, 0.7)]\n path_2a = Path(verts_2a, cubic_bezier_codes)\n\n # Decreasing a bit the y-value of the last control point leads to a\n # correct detection of path intersecting.\n verts_2b = [(0.5, 0.8), (0.5, 0.7), (0.6, 0.75), (0.56, 0.6)]\n path_2b = Path(verts_2b, cubic_bezier_codes)\n\n # Plot everything to be sure\n fig, (axA, axB) = plt.subplots(ncols=2, sharex=True, sharey=True)\n title_prefix = \"path_1.intersects_path(path_2):\\n\"\n for ax, p1, p2 in [(axA, path_1, path_2a), (axB, path_1, path_2b)]:\n # Detect if the two paths intersect\n detection = p1.intersects_path(p2)\n ax.set_title(title_prefix + \"{}\".format(detection))\n\n # Plot the two paths\n patch_1 = PathPatch(p1, lw=2, fc='none', ec='CornFlowerBlue')\n pc1 = ax.add_patch(patch_1)\n patch_2 = PathPatch(p2, lw=2, fc='none', ec=detection_color[detection])\n ax.add_patch(patch_2)\n\n # Plot the controls nodes for debugging\n ax = plot_ctrls(p1.vertices, ax, marker='s', color=patch_1.get_ec(),\n label='verts_1')\n ax = plot_ctrls(p2.vertices, ax, color=patch_2.get_ec(),\n label='verts_2')\n ax.legend(loc='lower right', handlelength=3.5)\n\n #fig.savefig(\"Issue_with_intersecting_path_detection.png\", dpi=150)\n\n```\n- [X] If this is an image generation bug attach a screenshot demonstrating the issue.\n\nThe paths are plotted in solid lines, and the vertices (control points) of the paths are plotted with markers (with thin dashed lines between them, and of the same color as the path they correspond to).\n- _Left panel_: the red path (path_2) is indicated as non intersecting with the blue one (path_1) by `path_1.intersects_path(path_2)`, while from the plot they seem to be intersecting… \n- _Right panel_: the green path (path_2) is indicated as intersecting with the blue one (path_1) by `path_1.intersects_path(path_2)`, which seems correct from the plot… \n\nThe only difference between the two red and green paths is their last control point (on the right), which is a bit lower in the right panel case than in the left panel case.\n\n\n- [X] If this is a regression (Used to work in an earlier version of Matplotlib), please \n note where it used to work.\n\nNever used `Path.intersects_path` method before, so I can't tell if it's a regression.\n","author":{"url":"https://github.com/afvincent","@type":"Person","name":"afvincent"},"datePublished":"2016-02-29T13:28:22.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/6076/matplotlib/issues/6076"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:da8e4f95-be58-a634-59d0-1d93be69c9ea |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BD28:135646:835568:B1F4D1:6A52AB40 |
| html-safe-nonce | 2e0e07c95a2b7fa22312ea9c865266cec8c72cd706afc5522f2e7f04947a840f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDI4OjEzNTY0Njo4MzU1Njg6QjFGNEQxOjZBNTJBQjQwIiwidmlzaXRvcl9pZCI6IjM4OTYxMjk1NzM3NTEwMDgwNjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c3651ce3c756329da60d2e72e856af108738e31dcf2a01018670d70c8b6e8915 |
| hovercard-subject-tag | issue:137254468 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/6076/issue_layout |
| twitter:image | https://opengraph.githubassets.com/028f57368f94936c851a36b96de79c105c4ccddee9636d1f53ea08f16115f4b4/matplotlib/matplotlib/issues/6076 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/028f57368f94936c851a36b96de79c105c4ccddee9636d1f53ea08f16115f4b4/matplotlib/matplotlib/issues/6076 |
| og:image:alt | Short Description I think there may be a bug in the Path.intersects_path method, in path module: Signature: Path.intersects_path(self, other, filled=True) Docstring: Returns *True* if this path int... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | afvincent |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width