{"id":19855821,"url":"https://github.com/cuixing158/pointpolygontest","last_synced_at":"2025-10-25T21:33:00.692Z","repository":{"id":153930363,"uuid":"556083026","full_name":"cuixing158/pointPolygonTest","owner":"cuixing158","description":"determine points are inside, on or outside a polygon/contour or  calculate signed distance between points and the nearest contour edge.","archived":false,"fork":false,"pushed_at":"2025-02-02T04:08:52.000Z","size":110,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T20:47:42.491Z","etag":null,"topics":["algorithm","c","computer-geometry"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cuixing158.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-10-23T02:36:46.000Z","updated_at":"2025-02-02T04:08:56.000Z","dependencies_parsed_at":"2023-11-19T00:26:53.162Z","dependency_job_id":"56a5cb13-425b-472f-9b06-a40c2c924b51","html_url":"https://github.com/cuixing158/pointPolygonTest","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuixing158%2FpointPolygonTest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuixing158%2FpointPolygonTest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuixing158%2FpointPolygonTest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuixing158%2FpointPolygonTest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cuixing158","download_url":"https://codeload.github.com/cuixing158/pointPolygonTest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251969396,"owners_count":21673194,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","c","computer-geometry"],"created_at":"2024-11-12T14:13:48.657Z","updated_at":"2025-10-25T21:33:00.686Z","avatar_url":"https://github.com/cuixing158.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![View pointPolygonTest on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://ww2.mathworks.cn/matlabcentral/fileexchange/119418-pointpolygontest) \n[![Open in MATLAB Online](https://www.mathworks.com/images/responsive/global/open-in-matlab-online.svg)](https://matlab.mathworks.com/open/github/v1?repo=cuixing158/pointPolygonTest\u0026file=demo.m)\n[![Sponsor](https://img.shields.io/badge/Sponsor-%E2%9D%A4-red)](https://raw.githubusercontent.com/cuixing158/OpticalFlow-Visualization/refs/heads/main/README_media/sponsors.jpg)\n\n# Points In Polygon Test\n\nThis function [`inpolygon2`](./inpolygon2.m) is an enhancement of matlab's built-in function [`inpolygon`](https://www.mathworks.com/help/matlab/ref/inpolygon.html), which supports the calculation of the distances.Support C/C++ code generation.\n\n:eyes:[View the example](https://viewer.mathworks.com/?viewer=plain_code\u0026url=https%3A%2F%2Fww2.mathworks.cn%2Fmatlabcentral%2Fmlc-downloads%2Fdownloads%2F86ed6463-8f26-4463-acc2-d739927612b1%2F53ec9495-8b54-49be-8855-fce595cdfa4e%2Ffiles%2Fdemo.m\u0026embed=web) \n:arrow_forward:[Run the example](https://matlab.mathworks.com/open/github/v1?repo=cuixing158/pointPolygonTest\u0026file=demo.m)\n\n## Example\n\n```matlab\n%% data, is same as https://www.mathworks.cn/help/matlab/ref/inpolygon.html fisrst Example\nL = linspace(0,2*pi,6);\nxv = cos(L)';\nyv = sin(L)';\n\nrng default\nxq = randn(250,1);\nyq = randn(250,1);\n\n%% use inpolygon2 function determine points whether inside polygon \npoints = [xq,yq];\ndists = inpolygon2([xv,yv],points);\n\nfigure;hold on\nplot(xv,yv) % polygon\nplot(xq(dists==1),yq(dists==1),'r+') % points inside\nplot(xq(dists==-1),yq(dists==-1),'bo') % points outside\naxis equal;\ntitle(\"points in polygon\")\n```\n\n![img](images/a.png)\n\n```matlab\n%% Distance Rating Heat Map\nxy=-2:.02:2;\n[x,y] = meshgrid(xy);\npoints = [x(:),y(:)];\ndists2 = inpolygon2([xv,yv],points,true);\ndists2 = reshape(dists2,size(x));\n\nfigure;hold on;\nxydata = [xy(1),xy(end)];\nimagesc(xydata,xydata,dists2)\nplot(xv,yv,'w-','LineWidth',2)\ncolormap('jet');\ncolorbar\naxis equal off\ntitle(\"signed distance hot map\")\n```\n\n![img](images/b.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuixing158%2Fpointpolygontest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcuixing158%2Fpointpolygontest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuixing158%2Fpointpolygontest/lists"}