{"action":"created","comment":{"url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/pulls/comments/115125329","pull_request_review_id":36648979,"id":115125329,"diff_hunk":"@@ -34,31 +34,21 @@ def point_on_edge?\n       edges.any? { |edge| edge.contains_point?(point) }\n     end\n \n-    def choose_good_ray\n-      ray = random_ray\n-      while ! good_ray?(ray) do\n-        ray = random_ray\n-      end\n-      ray\n-    end\n+    def point_inside_polygon?\n+      # Algorithm source:\n+      # https://wrf.ecse.rpi.edu//Research/Short_Notes/pnpoly.html\n \n-    def good_ray?(ray)\n-      edges.none? { |edge| !edge.length.zero? && edge.parallel_to?(ray) } && vertices.none? { |vertex| ray.contains_point?(vertex) }\n-    end\n-    \n-    def intersection_count(ray)\n-      edges.select { |edge| edge.intersects_with?(ray) }.size\n-    end\n-    \n-    def random_ray\n-      random_direction = rand * (2 * Math::PI)\n-      \n-      ray_endpoint = Point sufficient_ray_radius * Math.cos(random_direction), sufficient_ray_radius * Math.sin(random_direction)\n-      Segment point, ray_endpoint\n-    end\n+      result = false\n+\n+      vertices.each_with_index do |vertex, i|\n+        previous_vertex = vertices[i - 1] || vertex.last\n+        if ((vertex.y > point.y) != (previous_vertex.y > point.y)) &&\n+            (point.x < (previous_vertex.x - vertex.x) * (point.y - vertex.y) / (previous_vertex.y - vertex.y) + vertex.x)","path":"lib/geometry/algorithms/point_in_polygon.rb","position":52,"original_position":52,"commit_id":"bc692341b0ea2e43868370d5091b49d462f7a062","original_commit_id":"bc692341b0ea2e43868370d5091b49d462f7a062","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars3.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Align the operands of a condition in an if statement spanning multiple lines.<br>Line is too long. [121/80]","created_at":"2017-05-06T17:44:26Z","updated_at":"2017-05-06T17:44:26Z","html_url":"https://github.com/DanielVartanov/ruby-geometry/pull/17#discussion_r115125329","pull_request_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/DanielVartanov/ruby-geometry/pulls/comments/115125329"},"html":{"href":"https://github.com/DanielVartanov/ruby-geometry/pull/17#discussion_r115125329"},"pull_request":{"href":"https://api.github.com/repos/DanielVartanov/ruby-geometry/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/pulls/17","id":119308870,"html_url":"https://github.com/DanielVartanov/ruby-geometry/pull/17","diff_url":"https://github.com/DanielVartanov/ruby-geometry/pull/17.diff","patch_url":"https://github.com/DanielVartanov/ruby-geometry/pull/17.patch","issue_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/issues/17","number":17,"state":"open","locked":false,"title":"Deterministic algorithm to determine whether a point is in a polygon","user":{"login":"seangransee","id":1207531,"avatar_url":"https://avatars1.githubusercontent.com/u/1207531?v=3","gravatar_id":"","url":"https://api.github.com/users/seangransee","html_url":"https://github.com/seangransee","followers_url":"https://api.github.com/users/seangransee/followers","following_url":"https://api.github.com/users/seangransee/following{/other_user}","gists_url":"https://api.github.com/users/seangransee/gists{/gist_id}","starred_url":"https://api.github.com/users/seangransee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seangransee/subscriptions","organizations_url":"https://api.github.com/users/seangransee/orgs","repos_url":"https://api.github.com/users/seangransee/repos","events_url":"https://api.github.com/users/seangransee/events{/privacy}","received_events_url":"https://api.github.com/users/seangransee/received_events","type":"User","site_admin":false},"body":"I haven't gotten a chance to spend much time with this, but I've dropped in the algorithm I'm using in  my application to replace `Polygon.contains?`.\r\n\r\nThere's one failing test, which is the check for a point being on the edge of a convex polygon. As stated in the section [Point on a (Boundary) Edge](https://wrf.ecse.rpi.edu//Research/Short_Notes/pnpoly.html#Point%20on%20an%20Edge) from the algorithm's source page, this algorithm isn't able to predict when a point is exactly on the edge of a polygon. Perhaps a hybrid of this new algorithm with your current algorithm will do the trick.\r\n\r\nFeel free to mess around with this and push commits to my branch.","created_at":"2017-05-06T17:22:44Z","updated_at":"2017-05-06T17:44:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3bad99e56c7bc5bf363d43274b02d95c1f01e7de","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/pulls/17/commits","review_comments_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/pulls/17/comments","review_comment_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/issues/17/comments","statuses_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/statuses/bc692341b0ea2e43868370d5091b49d462f7a062","head":{"label":"seangransee:point-in-polygon","ref":"point-in-polygon","sha":"bc692341b0ea2e43868370d5091b49d462f7a062","user":{"login":"seangransee","id":1207531,"avatar_url":"https://avatars1.githubusercontent.com/u/1207531?v=3","gravatar_id":"","url":"https://api.github.com/users/seangransee","html_url":"https://github.com/seangransee","followers_url":"https://api.github.com/users/seangransee/followers","following_url":"https://api.github.com/users/seangransee/following{/other_user}","gists_url":"https://api.github.com/users/seangransee/gists{/gist_id}","starred_url":"https://api.github.com/users/seangransee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seangransee/subscriptions","organizations_url":"https://api.github.com/users/seangransee/orgs","repos_url":"https://api.github.com/users/seangransee/repos","events_url":"https://api.github.com/users/seangransee/events{/privacy}","received_events_url":"https://api.github.com/users/seangransee/received_events","type":"User","site_admin":false},"repo":{"id":90083901,"name":"ruby-geometry","full_name":"seangransee/ruby-geometry","owner":{"login":"seangransee","id":1207531,"avatar_url":"https://avatars1.githubusercontent.com/u/1207531?v=3","gravatar_id":"","url":"https://api.github.com/users/seangransee","html_url":"https://github.com/seangransee","followers_url":"https://api.github.com/users/seangransee/followers","following_url":"https://api.github.com/users/seangransee/following{/other_user}","gists_url":"https://api.github.com/users/seangransee/gists{/gist_id}","starred_url":"https://api.github.com/users/seangransee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seangransee/subscriptions","organizations_url":"https://api.github.com/users/seangransee/orgs","repos_url":"https://api.github.com/users/seangransee/repos","events_url":"https://api.github.com/users/seangransee/events{/privacy}","received_events_url":"https://api.github.com/users/seangransee/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/seangransee/ruby-geometry","description":"Simple geometry classes and algorithms in Ruby","fork":true,"url":"https://api.github.com/repos/seangransee/ruby-geometry","forks_url":"https://api.github.com/repos/seangransee/ruby-geometry/forks","keys_url":"https://api.github.com/repos/seangransee/ruby-geometry/keys{/key_id}","collaborators_url":"https://api.github.com/repos/seangransee/ruby-geometry/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/seangransee/ruby-geometry/teams","hooks_url":"https://api.github.com/repos/seangransee/ruby-geometry/hooks","issue_events_url":"https://api.github.com/repos/seangransee/ruby-geometry/issues/events{/number}","events_url":"https://api.github.com/repos/seangransee/ruby-geometry/events","assignees_url":"https://api.github.com/repos/seangransee/ruby-geometry/assignees{/user}","branches_url":"https://api.github.com/repos/seangransee/ruby-geometry/branches{/branch}","tags_url":"https://api.github.com/repos/seangransee/ruby-geometry/tags","blobs_url":"https://api.github.com/repos/seangransee/ruby-geometry/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/seangransee/ruby-geometry/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/seangransee/ruby-geometry/git/refs{/sha}","trees_url":"https://api.github.com/repos/seangransee/ruby-geometry/git/trees{/sha}","statuses_url":"https://api.github.com/repos/seangransee/ruby-geometry/statuses/{sha}","languages_url":"https://api.github.com/repos/seangransee/ruby-geometry/languages","stargazers_url":"https://api.github.com/repos/seangransee/ruby-geometry/stargazers","contributors_url":"https://api.github.com/repos/seangransee/ruby-geometry/contributors","subscribers_url":"https://api.github.com/repos/seangransee/ruby-geometry/subscribers","subscription_url":"https://api.github.com/repos/seangransee/ruby-geometry/subscription","commits_url":"https://api.github.com/repos/seangransee/ruby-geometry/commits{/sha}","git_commits_url":"https://api.github.com/repos/seangransee/ruby-geometry/git/commits{/sha}","comments_url":"https://api.github.com/repos/seangransee/ruby-geometry/comments{/number}","issue_comment_url":"https://api.github.com/repos/seangransee/ruby-geometry/issues/comments{/number}","contents_url":"https://api.github.com/repos/seangransee/ruby-geometry/contents/{+path}","compare_url":"https://api.github.com/repos/seangransee/ruby-geometry/compare/{base}...{head}","merges_url":"https://api.github.com/repos/seangransee/ruby-geometry/merges","archive_url":"https://api.github.com/repos/seangransee/ruby-geometry/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/seangransee/ruby-geometry/downloads","issues_url":"https://api.github.com/repos/seangransee/ruby-geometry/issues{/number}","pulls_url":"https://api.github.com/repos/seangransee/ruby-geometry/pulls{/number}","milestones_url":"https://api.github.com/repos/seangransee/ruby-geometry/milestones{/number}","notifications_url":"https://api.github.com/repos/seangransee/ruby-geometry/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/seangransee/ruby-geometry/labels{/name}","releases_url":"https://api.github.com/repos/seangransee/ruby-geometry/releases{/id}","deployments_url":"https://api.github.com/repos/seangransee/ruby-geometry/deployments","created_at":"2017-05-02T22:33:35Z","updated_at":"2017-05-02T22:33:37Z","pushed_at":"2017-05-06T17:32:03Z","git_url":"git://github.com/seangransee/ruby-geometry.git","ssh_url":"git@github.com:seangransee/ruby-geometry.git","clone_url":"https://github.com/seangransee/ruby-geometry.git","svn_url":"https://github.com/seangransee/ruby-geometry","homepage":"","size":99,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"DanielVartanov:master","ref":"master","sha":"5ee2eb0639589f7bcbd2356819ede2fd2708bae5","user":{"login":"DanielVartanov","id":21388,"avatar_url":"https://avatars0.githubusercontent.com/u/21388?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielVartanov","html_url":"https://github.com/DanielVartanov","followers_url":"https://api.github.com/users/DanielVartanov/followers","following_url":"https://api.github.com/users/DanielVartanov/following{/other_user}","gists_url":"https://api.github.com/users/DanielVartanov/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielVartanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielVartanov/subscriptions","organizations_url":"https://api.github.com/users/DanielVartanov/orgs","repos_url":"https://api.github.com/users/DanielVartanov/repos","events_url":"https://api.github.com/users/DanielVartanov/events{/privacy}","received_events_url":"https://api.github.com/users/DanielVartanov/received_events","type":"User","site_admin":false},"repo":{"id":44566,"name":"ruby-geometry","full_name":"DanielVartanov/ruby-geometry","owner":{"login":"DanielVartanov","id":21388,"avatar_url":"https://avatars0.githubusercontent.com/u/21388?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielVartanov","html_url":"https://github.com/DanielVartanov","followers_url":"https://api.github.com/users/DanielVartanov/followers","following_url":"https://api.github.com/users/DanielVartanov/following{/other_user}","gists_url":"https://api.github.com/users/DanielVartanov/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielVartanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielVartanov/subscriptions","organizations_url":"https://api.github.com/users/DanielVartanov/orgs","repos_url":"https://api.github.com/users/DanielVartanov/repos","events_url":"https://api.github.com/users/DanielVartanov/events{/privacy}","received_events_url":"https://api.github.com/users/DanielVartanov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DanielVartanov/ruby-geometry","description":"Simple geometry classes and algorithms in Ruby","fork":false,"url":"https://api.github.com/repos/DanielVartanov/ruby-geometry","forks_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/forks","keys_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/teams","hooks_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/hooks","issue_events_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/issues/events{/number}","events_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/events","assignees_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/assignees{/user}","branches_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/branches{/branch}","tags_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/tags","blobs_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/git/refs{/sha}","trees_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/statuses/{sha}","languages_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/languages","stargazers_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/stargazers","contributors_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/contributors","subscribers_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/subscribers","subscription_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/subscription","commits_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/commits{/sha}","git_commits_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/git/commits{/sha}","comments_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/comments{/number}","issue_comment_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/issues/comments{/number}","contents_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/contents/{+path}","compare_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/merges","archive_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/downloads","issues_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/issues{/number}","pulls_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/pulls{/number}","milestones_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/milestones{/number}","notifications_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/labels{/name}","releases_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/releases{/id}","deployments_url":"https://api.github.com/repos/DanielVartanov/ruby-geometry/deployments","created_at":"2008-08-21T11:43:10Z","updated_at":"2017-04-12T20:28:21Z","pushed_at":"2017-05-06T17:32:04Z","git_url":"git://github.com/DanielVartanov/ruby-geometry.git","ssh_url":"git@github.com:DanielVartanov/ruby-geometry.git","clone_url":"https://github.com/DanielVartanov/ruby-geometry.git","svn_url":"https://github.com/DanielVartanov/ruby-geometry","homepage":"","size":99,"stargazers_count":66,"watchers_count":66,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":31,"mirror_url":null,"open_issues_count":4,"forks":31,"open_issues":4,"watchers":66,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DanielVartanov/ruby-geometry/pulls/17"},"html":{"href":"https://github.com/DanielVartanov/ruby-geometry/pull/17"},"issue":{"href":"https://api.github.com/repos/DanielVartanov/ruby-geometry/issues/17"},"comments":{"href":"https://api.github.com/repos/DanielVartanov/ruby-geometry/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/DanielVartanov/ruby-geometry/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/DanielVartanov/ruby-geometry/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DanielVartanov/ruby-geometry/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/DanielVartanov/ruby-geometry/statuses/bc692341b0ea2e43868370d5091b49d462f7a062"}}}}
{"actor":{"display_login":"houndci-bot"}}