{"action":"created","comment":{"url":"https://api.github.com/repos/libgdx/box2dlights/pulls/comments/87721670","pull_request_review_id":8322423,"id":87721670,"diff_hunk":"@@ -0,0 +1,112 @@\n+package box2dLight;\n+\n+import com.badlogic.gdx.math.Vector2;\n+\n+/**\n+ * Created by PiotrJ on 06/11/2015.\n+ */\n+public class CircleUtils {\n+\tpublic static boolean findTangents (Vector2 center, float radius,\n+\t\tVector2 external,\n+\t\tVector2 oTanA, Vector2 oTanB) {\n+\n+\t\tfloat dx = center.x - external.x;\n+\t\tfloat dy = center.y - external.y;\n+\t\tfloat d2 = dx * dx + dy * dy;\n+\t\tif (d2 < radius * radius) {\n+\t\t\toTanA.set(Float.NaN, Float.NaN);\n+\t\t\toTanB.set(Float.NaN, Float.NaN);\n+\t\t\treturn false;\n+\t\t}\n+\t\tfloat len = (float)Math.sqrt(d2 - radius * radius);\n+\n+\t\tint inters = findCircleCircleIntersection(\n+\t\t\tcenter.x, center.y, radius,\n+\t\t\texternal.x, external.y, len,\n+\t\t\toTanA, oTanB\n+\t\t);\n+\t\treturn inters > 1;\n+\t}\n+\n+\tpublic static int findCircleCircleIntersection (\n+\t\tfloat x1, float y1, float r1,\n+\t\tfloat x2, float y2, float r2,\n+\t\tVector2 outA, Vector2 outB\n+\t) {\n+\t\tfloat dx = x1 - x2;\n+\t\tfloat dy = y1 - y2;\n+\t\tfloat dist = (float)Math.sqrt(dx * dx + dy * dy);\n+\t\tif (dist > r1 + r2) {\n+\t\t\t// No solutions, the circles are too far apart.\n+\t\t\toutA.set(Float.NaN, Float.NaN);\n+\t\t\toutB.set(Float.NaN, Float.NaN);\n+\t\t\treturn 0;\n+\t\t} else if (dist < Math.abs(r1 - r2)) {\n+\t\t\t// No solutions, one circle contains the other.\n+\t\t\toutA.set(Float.NaN, Float.NaN);\n+\t\t\toutB.set(Float.NaN, Float.NaN);\n+\t\t\treturn 0;\n+\t\t} else if ((dist == 0) && (r1 == r2)) {\n+\t\t\t// No solutions, the circles coincide.\n+\t\t\toutA.set(Float.NaN, Float.NaN);\n+\t\t\toutB.set(Float.NaN, Float.NaN);\n+\t\t\treturn 0;\n+\t\t} else {\n+\t\t\t// Find a and h.\n+\t\t\tfloat a = (r1 * r1 -\n+\t\t\t\tr2 * r2 + dist * dist) / (2 * dist);\n+\t\t\tfloat h = (float)Math.sqrt(r1 * r1 - a * a);\n+\n+\t\t\t// Find P2.\n+\t\t\tfloat x3 = x1 + a * (x2 - x1) / dist;\n+\t\t\tfloat cy2 = y1 + a * (y2 - y1) / dist;\n+\n+\t\t\t// Get the points P3.\n+\t\t\toutA.set(\n+\t\t\t\tx3 + h * (y2 - y1) / dist,\n+\t\t\t\tcy2 - h * (x2 - x1) / dist);\n+\t\t\toutB.set(\n+\t\t\t\tx3 - h * (y2 - y1) / dist,\n+\t\t\t\tcy2 + h * (x2 - x1) / dist);\n+\n+\t\t\t// See if we have 1 or 2 solutions.\n+\t\t\tif (dist == r1 + r2) return 1;\n+\t\t\treturn 2;\n+\t\t}\n+\t}\n+\n+\tpublic static int findIntersections (Vector2 center, float radius,\n+\t\t\tVector2 start, Vector2 end, Vector2 intA, Vector2 intB) {\n+\t\t// find intersection with quadratic formula\n+\t\tfloat dx, dy, A, B, C, det, t;\n+\n+\t\tdx = end.x - start.x;\n+\t\tdy = end.y - start.y;\n+\n+\t\tA = dx * dx + dy * dy;\n+\t\tB = 2 * (dx * (start.x - center.x) + dy * (start.y - center.y));\n+\t\tC = (start.x - center.x) * (start.x - center.x) + (start.y - center.y)\n+\t\t\t\t* (start.y - center.y) - radius * radius;\n+\n+\t\tdet = B * B - 4 * A * C;\n+\t\tif ((A <= 0.001f) || (det < 0)) {","path":"src/box2dLight/CircleUtils.java","position":92,"original_position":92,"commit_id":"4ec7ab46b446ddb21dcd84ac351a698ae820adca","original_commit_id":"4ec7ab46b446ddb21dcd84ac351a698ae820adca","user":{"login":"piotr-j","id":2499728,"avatar_url":"https://avatars.githubusercontent.com/u/2499728?v=3","gravatar_id":"","url":"https://api.github.com/users/piotr-j","html_url":"https://github.com/piotr-j","followers_url":"https://api.github.com/users/piotr-j/followers","following_url":"https://api.github.com/users/piotr-j/following{/other_user}","gists_url":"https://api.github.com/users/piotr-j/gists{/gist_id}","starred_url":"https://api.github.com/users/piotr-j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piotr-j/subscriptions","organizations_url":"https://api.github.com/users/piotr-j/orgs","repos_url":"https://api.github.com/users/piotr-j/repos","events_url":"https://api.github.com/users/piotr-j/events{/privacy}","received_events_url":"https://api.github.com/users/piotr-j/received_events","type":"User","site_admin":false},"body":"Its just close enough to 0 kinda deal, epsilon if you will. The real reason is math that I cant remember at this point.","created_at":"2016-11-13T21:05:54Z","updated_at":"2016-11-13T21:05:54Z","html_url":"https://github.com/libgdx/box2dlights/pull/99#discussion_r87721670","pull_request_url":"https://api.github.com/repos/libgdx/box2dlights/pulls/99","_links":{"self":{"href":"https://api.github.com/repos/libgdx/box2dlights/pulls/comments/87721670"},"html":{"href":"https://github.com/libgdx/box2dlights/pull/99#discussion_r87721670"},"pull_request":{"href":"https://api.github.com/repos/libgdx/box2dlights/pulls/99"}}},"pull_request":{"url":"https://api.github.com/repos/libgdx/box2dlights/pulls/99","id":92558682,"html_url":"https://github.com/libgdx/box2dlights/pull/99","diff_url":"https://github.com/libgdx/box2dlights/pull/99.diff","patch_url":"https://github.com/libgdx/box2dlights/pull/99.patch","issue_url":"https://api.github.com/repos/libgdx/box2dlights/issues/99","number":99,"state":"open","locked":false,"title":"Added smooth lights","user":{"login":"piotr-j","id":2499728,"avatar_url":"https://avatars.githubusercontent.com/u/2499728?v=3","gravatar_id":"","url":"https://api.github.com/users/piotr-j","html_url":"https://github.com/piotr-j","followers_url":"https://api.github.com/users/piotr-j/followers","following_url":"https://api.github.com/users/piotr-j/following{/other_user}","gists_url":"https://api.github.com/users/piotr-j/gists{/gist_id}","starred_url":"https://api.github.com/users/piotr-j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piotr-j/subscriptions","organizations_url":"https://api.github.com/users/piotr-j/orgs","repos_url":"https://api.github.com/users/piotr-j/repos","events_url":"https://api.github.com/users/piotr-j/events{/privacy}","received_events_url":"https://api.github.com/users/piotr-j/received_events","type":"User","site_admin":false},"body":"Smooth lights are a drop in replacement for current lights. They cast rays more intelligently allowing to use less rays then comparable default light. See https://www.youtube.com/watch?v=24XHJPjpxy4 for example.\r\n\r\nCode review would be great!","created_at":"2016-11-07T10:36:59Z","updated_at":"2016-11-13T21:05:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c677ac1364555e0db411bb61dee549b35994557d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/libgdx/box2dlights/pulls/99/commits","review_comments_url":"https://api.github.com/repos/libgdx/box2dlights/pulls/99/comments","review_comment_url":"https://api.github.com/repos/libgdx/box2dlights/pulls/comments{/number}","comments_url":"https://api.github.com/repos/libgdx/box2dlights/issues/99/comments","statuses_url":"https://api.github.com/repos/libgdx/box2dlights/statuses/4ec7ab46b446ddb21dcd84ac351a698ae820adca","head":{"label":"piotr-j:master","ref":"master","sha":"4ec7ab46b446ddb21dcd84ac351a698ae820adca","user":{"login":"piotr-j","id":2499728,"avatar_url":"https://avatars.githubusercontent.com/u/2499728?v=3","gravatar_id":"","url":"https://api.github.com/users/piotr-j","html_url":"https://github.com/piotr-j","followers_url":"https://api.github.com/users/piotr-j/followers","following_url":"https://api.github.com/users/piotr-j/following{/other_user}","gists_url":"https://api.github.com/users/piotr-j/gists{/gist_id}","starred_url":"https://api.github.com/users/piotr-j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piotr-j/subscriptions","organizations_url":"https://api.github.com/users/piotr-j/orgs","repos_url":"https://api.github.com/users/piotr-j/repos","events_url":"https://api.github.com/users/piotr-j/events{/privacy}","received_events_url":"https://api.github.com/users/piotr-j/received_events","type":"User","site_admin":false},"repo":{"id":32475776,"name":"box2dlights","full_name":"piotr-j/box2dlights","owner":{"login":"piotr-j","id":2499728,"avatar_url":"https://avatars.githubusercontent.com/u/2499728?v=3","gravatar_id":"","url":"https://api.github.com/users/piotr-j","html_url":"https://github.com/piotr-j","followers_url":"https://api.github.com/users/piotr-j/followers","following_url":"https://api.github.com/users/piotr-j/following{/other_user}","gists_url":"https://api.github.com/users/piotr-j/gists{/gist_id}","starred_url":"https://api.github.com/users/piotr-j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piotr-j/subscriptions","organizations_url":"https://api.github.com/users/piotr-j/orgs","repos_url":"https://api.github.com/users/piotr-j/repos","events_url":"https://api.github.com/users/piotr-j/events{/privacy}","received_events_url":"https://api.github.com/users/piotr-j/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/piotr-j/box2dlights","description":"Fork of box2dlights by Kalle Hamalainen","fork":true,"url":"https://api.github.com/repos/piotr-j/box2dlights","forks_url":"https://api.github.com/repos/piotr-j/box2dlights/forks","keys_url":"https://api.github.com/repos/piotr-j/box2dlights/keys{/key_id}","collaborators_url":"https://api.github.com/repos/piotr-j/box2dlights/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/piotr-j/box2dlights/teams","hooks_url":"https://api.github.com/repos/piotr-j/box2dlights/hooks","issue_events_url":"https://api.github.com/repos/piotr-j/box2dlights/issues/events{/number}","events_url":"https://api.github.com/repos/piotr-j/box2dlights/events","assignees_url":"https://api.github.com/repos/piotr-j/box2dlights/assignees{/user}","branches_url":"https://api.github.com/repos/piotr-j/box2dlights/branches{/branch}","tags_url":"https://api.github.com/repos/piotr-j/box2dlights/tags","blobs_url":"https://api.github.com/repos/piotr-j/box2dlights/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/piotr-j/box2dlights/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/piotr-j/box2dlights/git/refs{/sha}","trees_url":"https://api.github.com/repos/piotr-j/box2dlights/git/trees{/sha}","statuses_url":"https://api.github.com/repos/piotr-j/box2dlights/statuses/{sha}","languages_url":"https://api.github.com/repos/piotr-j/box2dlights/languages","stargazers_url":"https://api.github.com/repos/piotr-j/box2dlights/stargazers","contributors_url":"https://api.github.com/repos/piotr-j/box2dlights/contributors","subscribers_url":"https://api.github.com/repos/piotr-j/box2dlights/subscribers","subscription_url":"https://api.github.com/repos/piotr-j/box2dlights/subscription","commits_url":"https://api.github.com/repos/piotr-j/box2dlights/commits{/sha}","git_commits_url":"https://api.github.com/repos/piotr-j/box2dlights/git/commits{/sha}","comments_url":"https://api.github.com/repos/piotr-j/box2dlights/comments{/number}","issue_comment_url":"https://api.github.com/repos/piotr-j/box2dlights/issues/comments{/number}","contents_url":"https://api.github.com/repos/piotr-j/box2dlights/contents/{+path}","compare_url":"https://api.github.com/repos/piotr-j/box2dlights/compare/{base}...{head}","merges_url":"https://api.github.com/repos/piotr-j/box2dlights/merges","archive_url":"https://api.github.com/repos/piotr-j/box2dlights/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/piotr-j/box2dlights/downloads","issues_url":"https://api.github.com/repos/piotr-j/box2dlights/issues{/number}","pulls_url":"https://api.github.com/repos/piotr-j/box2dlights/pulls{/number}","milestones_url":"https://api.github.com/repos/piotr-j/box2dlights/milestones{/number}","notifications_url":"https://api.github.com/repos/piotr-j/box2dlights/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/piotr-j/box2dlights/labels{/name}","releases_url":"https://api.github.com/repos/piotr-j/box2dlights/releases{/id}","deployments_url":"https://api.github.com/repos/piotr-j/box2dlights/deployments","created_at":"2015-03-18T18:06:31Z","updated_at":"2016-11-06T23:31:52Z","pushed_at":"2016-11-06T11:25:48Z","git_url":"git://github.com/piotr-j/box2dlights.git","ssh_url":"git@github.com:piotr-j/box2dlights.git","clone_url":"https://github.com/piotr-j/box2dlights.git","svn_url":"https://github.com/piotr-j/box2dlights","homepage":null,"size":611,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":false,"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":2,"default_branch":"master"}},"base":{"label":"libgdx:master","ref":"master","sha":"af9f8f4d01e4c1f4d2f05683c8836251a9ca703c","user":{"login":"libgdx","id":509841,"avatar_url":"https://avatars.githubusercontent.com/u/509841?v=3","gravatar_id":"","url":"https://api.github.com/users/libgdx","html_url":"https://github.com/libgdx","followers_url":"https://api.github.com/users/libgdx/followers","following_url":"https://api.github.com/users/libgdx/following{/other_user}","gists_url":"https://api.github.com/users/libgdx/gists{/gist_id}","starred_url":"https://api.github.com/users/libgdx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libgdx/subscriptions","organizations_url":"https://api.github.com/users/libgdx/orgs","repos_url":"https://api.github.com/users/libgdx/repos","events_url":"https://api.github.com/users/libgdx/events{/privacy}","received_events_url":"https://api.github.com/users/libgdx/received_events","type":"Organization","site_admin":false},"repo":{"id":17802765,"name":"box2dlights","full_name":"libgdx/box2dlights","owner":{"login":"libgdx","id":509841,"avatar_url":"https://avatars.githubusercontent.com/u/509841?v=3","gravatar_id":"","url":"https://api.github.com/users/libgdx","html_url":"https://github.com/libgdx","followers_url":"https://api.github.com/users/libgdx/followers","following_url":"https://api.github.com/users/libgdx/following{/other_user}","gists_url":"https://api.github.com/users/libgdx/gists{/gist_id}","starred_url":"https://api.github.com/users/libgdx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libgdx/subscriptions","organizations_url":"https://api.github.com/users/libgdx/orgs","repos_url":"https://api.github.com/users/libgdx/repos","events_url":"https://api.github.com/users/libgdx/events{/privacy}","received_events_url":"https://api.github.com/users/libgdx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/libgdx/box2dlights","description":"Fork of box2dlights by Kalle Hamalainen","fork":false,"url":"https://api.github.com/repos/libgdx/box2dlights","forks_url":"https://api.github.com/repos/libgdx/box2dlights/forks","keys_url":"https://api.github.com/repos/libgdx/box2dlights/keys{/key_id}","collaborators_url":"https://api.github.com/repos/libgdx/box2dlights/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/libgdx/box2dlights/teams","hooks_url":"https://api.github.com/repos/libgdx/box2dlights/hooks","issue_events_url":"https://api.github.com/repos/libgdx/box2dlights/issues/events{/number}","events_url":"https://api.github.com/repos/libgdx/box2dlights/events","assignees_url":"https://api.github.com/repos/libgdx/box2dlights/assignees{/user}","branches_url":"https://api.github.com/repos/libgdx/box2dlights/branches{/branch}","tags_url":"https://api.github.com/repos/libgdx/box2dlights/tags","blobs_url":"https://api.github.com/repos/libgdx/box2dlights/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/libgdx/box2dlights/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/libgdx/box2dlights/git/refs{/sha}","trees_url":"https://api.github.com/repos/libgdx/box2dlights/git/trees{/sha}","statuses_url":"https://api.github.com/repos/libgdx/box2dlights/statuses/{sha}","languages_url":"https://api.github.com/repos/libgdx/box2dlights/languages","stargazers_url":"https://api.github.com/repos/libgdx/box2dlights/stargazers","contributors_url":"https://api.github.com/repos/libgdx/box2dlights/contributors","subscribers_url":"https://api.github.com/repos/libgdx/box2dlights/subscribers","subscription_url":"https://api.github.com/repos/libgdx/box2dlights/subscription","commits_url":"https://api.github.com/repos/libgdx/box2dlights/commits{/sha}","git_commits_url":"https://api.github.com/repos/libgdx/box2dlights/git/commits{/sha}","comments_url":"https://api.github.com/repos/libgdx/box2dlights/comments{/number}","issue_comment_url":"https://api.github.com/repos/libgdx/box2dlights/issues/comments{/number}","contents_url":"https://api.github.com/repos/libgdx/box2dlights/contents/{+path}","compare_url":"https://api.github.com/repos/libgdx/box2dlights/compare/{base}...{head}","merges_url":"https://api.github.com/repos/libgdx/box2dlights/merges","archive_url":"https://api.github.com/repos/libgdx/box2dlights/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/libgdx/box2dlights/downloads","issues_url":"https://api.github.com/repos/libgdx/box2dlights/issues{/number}","pulls_url":"https://api.github.com/repos/libgdx/box2dlights/pulls{/number}","milestones_url":"https://api.github.com/repos/libgdx/box2dlights/milestones{/number}","notifications_url":"https://api.github.com/repos/libgdx/box2dlights/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/libgdx/box2dlights/labels{/name}","releases_url":"https://api.github.com/repos/libgdx/box2dlights/releases{/id}","deployments_url":"https://api.github.com/repos/libgdx/box2dlights/deployments","created_at":"2014-03-16T15:56:38Z","updated_at":"2016-11-12T22:49:39Z","pushed_at":"2016-11-07T10:36:59Z","git_url":"git://github.com/libgdx/box2dlights.git","ssh_url":"git@github.com:libgdx/box2dlights.git","clone_url":"https://github.com/libgdx/box2dlights.git","svn_url":"https://github.com/libgdx/box2dlights","homepage":null,"size":1245,"stargazers_count":158,"watchers_count":158,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":58,"mirror_url":null,"open_issues_count":25,"forks":58,"open_issues":25,"watchers":158,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/libgdx/box2dlights/pulls/99"},"html":{"href":"https://github.com/libgdx/box2dlights/pull/99"},"issue":{"href":"https://api.github.com/repos/libgdx/box2dlights/issues/99"},"comments":{"href":"https://api.github.com/repos/libgdx/box2dlights/issues/99/comments"},"review_comments":{"href":"https://api.github.com/repos/libgdx/box2dlights/pulls/99/comments"},"review_comment":{"href":"https://api.github.com/repos/libgdx/box2dlights/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/libgdx/box2dlights/pulls/99/commits"},"statuses":{"href":"https://api.github.com/repos/libgdx/box2dlights/statuses/4ec7ab46b446ddb21dcd84ac351a698ae820adca"}}}}
{"actor":{"display_login":"piotr-j"}}