{"action":"created","comment":{"url":"https://api.github.com/repos/processing-js/processing-js/pulls/comments/37449067","id":37449067,"diff_hunk":"@@ -0,0 +1,283 @@\n+module.exports = function(options, undef) {\n+  'use strict';\n+\n+  const TAU = 2 * Math.PI,\n+        //TAU = options.PConstants.TAU,\n+        lerp = function(start, stop, amt) {\n+          return amt * (stop - start) + start;\n+        },\n+        sq = function(n) {\n+          return n*n;\n+        },\n+        argsErr = function(mtd, len, min) {\n+          throw 'Too few args passed to ' + mtd +\n+                '() [' + len + ' < ' + min + '].';\n+        };\n+\n+  function _PVector(x, y, z) {\n+    this.x = +x || 0;\n+    this.y = +y || 0;\n+    this.z = +z || 0;\n+  }\n+\n+  _PVector.fromAngle = function(angle, target) {\n+    return target? target.set(Math.cos(angle), Math.sin(angle))\n+                 : new _PVector(Math.cos(angle), Math.sin(angle));\n+  };\n+\n+  _PVector.random2D = function(target, parent) {\n+    //const rnd = parent? parent : target instanceof Processing? target : Math;\n+    const rnd = parent? parent : target && target.random? target : Math;\n+    return _PVector.fromAngle(TAU * rnd.random(), target);\n+  };\n+\n+  _PVector.random3D = function(target, parent) {\n+    //const rnd = parent? parent : target instanceof Processing? target : Math,\n+    const rnd = parent? parent : target && target.random? target : Math,\n+          ang = TAU * rnd.random(),\n+          vz  = 2 * rnd.random() - 1,\n+          vzr = Math.sqrt(1 - vz*vz),\n+          vx  = vzr * Math.cos(ang),\n+          vy  = vzr * Math.sin(ang);\n+    return target? target.set(vx, vy, vz) : new _PVector(vx, vy, vz);\n+  };\n+\n+  _PVector.dist = function(v1, v2) {\n+    return Math.sqrt(_PVector.distSq(v1, v2));\n+  };\n+\n+  _PVector.distSq = function(v1, v2) {\n+    return sq(v1.x - v2.x) + sq(v1.y - v2.y) + sq(v1.z - v2.z);\n+  };\n+\n+  _PVector.dot = function(v1, v2) {\n+    return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;\n+  };\n+\n+  _PVector.cross = function(v1, v2, target) {\n+    const cx = v1.y*v2.z - v2.y*v1.z,\n+          cy = v1.z*v2.x - v2.z*v1.x,\n+          cz = v1.x*v2.y - v2.x*v1.y;\n+    return target? target.set(cx, cy, cz) : new _PVector(cx, cy, cz);\n+  };\n+\n+  _PVector.angleBetween = function(v1, v2) {\n+    if (!v1.x && !v1.y && !v1.z || !v2.x && !v2.y && !v2.z) { return 0; }\n+    const amt = _PVector.dot(v1, v2) / Math.sqrt(v1.magSq() * v2.magSq());\n+    return amt <= -1? Math.PI : amt >= 1? 0 : Math.acos(amt);\n+  };\n+\n+  _PVector.lerp = function(v1, v2, amt) {\n+    return v1.copy().lerp(v2, amt);\n+  };\n+\n+  _PVector.add = function(v1, v2, target) {\n+    return target? target.set(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z)\n+                 : new _PVector(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);\n+  };\n+\n+  _PVector.sub = function(v1, v2, target) {\n+    return target? target.set(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z)\n+                 : new _PVector(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);\n+  };\n+\n+  _PVector.mult = function(v, n, target) {\n+    if (typeof n === 'number') {\n+      return target? target.set(v.x*n, v.y*n, v.z*n)\n+                   : new _PVector(v.x*n, v.y*n, v.z*n);\n+    }\n+    return target? target.set(v.x*n.x, v.y*n.y, v.z*n.z)\n+                 : new _PVector(v.x*n.x, v.y*n.y, v.z*n.z);\n+  };\n+\n+  _PVector.div = function(v, n, target) {\n+    if (typeof n === 'number') {\n+      return target? target.set(v.x/n, v.y/n, v.z/n)\n+                   : new _PVector(v.x/n, v.y/n, v.z/n);\n+    }\n+    return target? target.set(v.x/n.x, v.y/n.y, v.z/n.z)\n+                 : new _PVector(v.x/n.x, v.y/n.y, v.z/n.z);\n+  };\n+\n+  _PVector.prototype = {\n+    copy: function() {\n+      return new _PVector(this.x, this.y, this.z);\n+    },\n+    get: function(target) {\n+      if (!arguments.length) { return this.copy(); } // @Deprecated\n+      if (typeof target !== 'object') { return this.array(); }\n+      target[0] = this.x;\n+      target[1] = this.y;\n+      target[2] = this.z;\n+      return target;\n+    },\n+    set: function(v, y, z) {\n+      const len = arguments.length;\n+      if (len > 1) {\n+        this.x = v;\n+        this.y = y;\n+        if (len > 2) { this.z = z; }\n+      } else if (len === 1) {\n+        this.set(v.x || v[0] || 0,\n+                 v.y || v[1] || 0,\n+                 v.z || v[2] || 0);\n+      } else { argsErr('set', len, 1); }\n+      return this;\n+    },\n+    array: function() {\n+      return [this.x, this.y, this.z];\n+    },\n+    normalize: function(target) {\n+      const m = this.mag(),\n+            canDivide = m !== 0 && m !== 1;\n+      if (!arguments.length) { return canDivide? this.div(m) : this; }\n+      return canDivide? _PVector.div(this, m, target)\n+                      : target? target.set(this) : this.copy();\n+    },\n+    limit: function(max) {\n+      return this.magSq() > max*max? this.normalize().mult(max) : this;\n+    },\n+    heading: function() {\n+      //return -Math.atan2(-this.y, this.x);\n+      return Math.atan2(this.y, this.x);\n+    },\n+    heading2D: null, // @Deprecated\n+    mag: function() {\n+      return Math.sqrt(this.magSq());\n+    },\n+    magSq: function() {\n+      return sq(this.x) + sq(this.y) + sq(this.z);\n+    },\n+    setMag: function(target, length) {\n+      const len = arguments.length;\n+      return len === 1? this.normalize().mult(target) :\n+             len > 1? this.normalize(target).mult(length) :\n+             argsErr('setMag', len, 1);\n+    },\n+    rotate: function(angle) {\n+      const prev_x = this.x,","path":"src/Objects/_PVector.js","position":158,"original_position":158,"commit_id":"2fdb36b65d4d2e58e8726439b08ecb7df2aaf810","original_commit_id":"2fdb36b65d4d2e58e8726439b08ecb7df2aaf810","user":{"login":"Pomax","id":177243,"avatar_url":"https://avatars.githubusercontent.com/u/177243?v=3","gravatar_id":"","url":"https://api.github.com/users/Pomax","html_url":"https://github.com/Pomax","followers_url":"https://api.github.com/users/Pomax/followers","following_url":"https://api.github.com/users/Pomax/following{/other_user}","gists_url":"https://api.github.com/users/Pomax/gists{/gist_id}","starred_url":"https://api.github.com/users/Pomax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pomax/subscriptions","organizations_url":"https://api.github.com/users/Pomax/orgs","repos_url":"https://api.github.com/users/Pomax/repos","events_url":"https://api.github.com/users/Pomax/events{/privacy}","received_events_url":"https://api.github.com/users/Pomax/received_events","type":"User","site_admin":false},"body":"`var`","created_at":"2015-08-19T18:22:27Z","updated_at":"2015-08-19T18:22:27Z","html_url":"https://github.com/processing-js/processing-js/pull/201#discussion_r37449067","pull_request_url":"https://api.github.com/repos/processing-js/processing-js/pulls/201","_links":{"self":{"href":"https://api.github.com/repos/processing-js/processing-js/pulls/comments/37449067"},"html":{"href":"https://github.com/processing-js/processing-js/pull/201#discussion_r37449067"},"pull_request":{"href":"https://api.github.com/repos/processing-js/processing-js/pulls/201"}}},"pull_request":{"url":"https://api.github.com/repos/processing-js/processing-js/pulls/201","id":42843379,"html_url":"https://github.com/processing-js/processing-js/pull/201","diff_url":"https://github.com/processing-js/processing-js/pull/201.diff","patch_url":"https://github.com/processing-js/processing-js/pull/201.patch","issue_url":"https://api.github.com/repos/processing-js/processing-js/issues/201","number":201,"state":"open","locked":false,"title":"Next PVector Class","user":{"login":"GoToLoop","id":6551569,"avatar_url":"https://avatars.githubusercontent.com/u/6551569?v=3","gravatar_id":"","url":"https://api.github.com/users/GoToLoop","html_url":"https://github.com/GoToLoop","followers_url":"https://api.github.com/users/GoToLoop/followers","following_url":"https://api.github.com/users/GoToLoop/following{/other_user}","gists_url":"https://api.github.com/users/GoToLoop/gists{/gist_id}","starred_url":"https://api.github.com/users/GoToLoop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoToLoop/subscriptions","organizations_url":"https://api.github.com/users/GoToLoop/orgs","repos_url":"https://api.github.com/users/GoToLoop/repos","events_url":"https://api.github.com/users/GoToLoop/events{/privacy}","received_events_url":"https://api.github.com/users/GoToLoop/received_events","type":"User","site_admin":false},"body":"https://gist.github.com/GoToLoop/acbf106aa784820aff23\r\nhttps://github.com/processing/processing/blob/master/core/src/processing/core/PVector.java\r\nhttps://github.com/processing-js/processing-js/blob/master/src/Objects/PVector.js\r\nhttps://github.com/processing-js/processing-js/issues/200","created_at":"2015-08-19T17:48:11Z","updated_at":"2015-08-19T18:22:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e9c83f8a8918b0d8989050a8b9f4d0adce81c65e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/processing-js/processing-js/pulls/201/commits","review_comments_url":"https://api.github.com/repos/processing-js/processing-js/pulls/201/comments","review_comment_url":"https://api.github.com/repos/processing-js/processing-js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/processing-js/processing-js/issues/201/comments","statuses_url":"https://api.github.com/repos/processing-js/processing-js/statuses/2fdb36b65d4d2e58e8726439b08ecb7df2aaf810","head":{"label":"GoToLoop:patch-1","ref":"patch-1","sha":"2fdb36b65d4d2e58e8726439b08ecb7df2aaf810","user":{"login":"GoToLoop","id":6551569,"avatar_url":"https://avatars.githubusercontent.com/u/6551569?v=3","gravatar_id":"","url":"https://api.github.com/users/GoToLoop","html_url":"https://github.com/GoToLoop","followers_url":"https://api.github.com/users/GoToLoop/followers","following_url":"https://api.github.com/users/GoToLoop/following{/other_user}","gists_url":"https://api.github.com/users/GoToLoop/gists{/gist_id}","starred_url":"https://api.github.com/users/GoToLoop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoToLoop/subscriptions","organizations_url":"https://api.github.com/users/GoToLoop/orgs","repos_url":"https://api.github.com/users/GoToLoop/repos","events_url":"https://api.github.com/users/GoToLoop/events{/privacy}","received_events_url":"https://api.github.com/users/GoToLoop/received_events","type":"User","site_admin":false},"repo":{"id":41049945,"name":"processing-js","full_name":"GoToLoop/processing-js","owner":{"login":"GoToLoop","id":6551569,"avatar_url":"https://avatars.githubusercontent.com/u/6551569?v=3","gravatar_id":"","url":"https://api.github.com/users/GoToLoop","html_url":"https://github.com/GoToLoop","followers_url":"https://api.github.com/users/GoToLoop/followers","following_url":"https://api.github.com/users/GoToLoop/following{/other_user}","gists_url":"https://api.github.com/users/GoToLoop/gists{/gist_id}","starred_url":"https://api.github.com/users/GoToLoop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoToLoop/subscriptions","organizations_url":"https://api.github.com/users/GoToLoop/orgs","repos_url":"https://api.github.com/users/GoToLoop/repos","events_url":"https://api.github.com/users/GoToLoop/events{/privacy}","received_events_url":"https://api.github.com/users/GoToLoop/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/GoToLoop/processing-js","description":"A port of the Processing visualization language to JavaScript.","fork":true,"url":"https://api.github.com/repos/GoToLoop/processing-js","forks_url":"https://api.github.com/repos/GoToLoop/processing-js/forks","keys_url":"https://api.github.com/repos/GoToLoop/processing-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoToLoop/processing-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoToLoop/processing-js/teams","hooks_url":"https://api.github.com/repos/GoToLoop/processing-js/hooks","issue_events_url":"https://api.github.com/repos/GoToLoop/processing-js/issues/events{/number}","events_url":"https://api.github.com/repos/GoToLoop/processing-js/events","assignees_url":"https://api.github.com/repos/GoToLoop/processing-js/assignees{/user}","branches_url":"https://api.github.com/repos/GoToLoop/processing-js/branches{/branch}","tags_url":"https://api.github.com/repos/GoToLoop/processing-js/tags","blobs_url":"https://api.github.com/repos/GoToLoop/processing-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoToLoop/processing-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoToLoop/processing-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoToLoop/processing-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoToLoop/processing-js/statuses/{sha}","languages_url":"https://api.github.com/repos/GoToLoop/processing-js/languages","stargazers_url":"https://api.github.com/repos/GoToLoop/processing-js/stargazers","contributors_url":"https://api.github.com/repos/GoToLoop/processing-js/contributors","subscribers_url":"https://api.github.com/repos/GoToLoop/processing-js/subscribers","subscription_url":"https://api.github.com/repos/GoToLoop/processing-js/subscription","commits_url":"https://api.github.com/repos/GoToLoop/processing-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoToLoop/processing-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoToLoop/processing-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoToLoop/processing-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoToLoop/processing-js/contents/{+path}","compare_url":"https://api.github.com/repos/GoToLoop/processing-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoToLoop/processing-js/merges","archive_url":"https://api.github.com/repos/GoToLoop/processing-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoToLoop/processing-js/downloads","issues_url":"https://api.github.com/repos/GoToLoop/processing-js/issues{/number}","pulls_url":"https://api.github.com/repos/GoToLoop/processing-js/pulls{/number}","milestones_url":"https://api.github.com/repos/GoToLoop/processing-js/milestones{/number}","notifications_url":"https://api.github.com/repos/GoToLoop/processing-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoToLoop/processing-js/labels{/name}","releases_url":"https://api.github.com/repos/GoToLoop/processing-js/releases{/id}","created_at":"2015-08-19T17:42:09Z","updated_at":"2015-08-19T17:42:13Z","pushed_at":"2015-08-19T17:47:28Z","git_url":"git://github.com/GoToLoop/processing-js.git","ssh_url":"git@github.com:GoToLoop/processing-js.git","clone_url":"https://github.com/GoToLoop/processing-js.git","svn_url":"https://github.com/GoToLoop/processing-js","homepage":"http://processingjs.org/","size":44251,"stargazers_count":0,"watchers_count":0,"language":"Processing","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"processing-js:master","ref":"master","sha":"5f4d018dda813792ffd13ca9e7ba4ef12468f637","user":{"login":"processing-js","id":1197580,"avatar_url":"https://avatars.githubusercontent.com/u/1197580?v=3","gravatar_id":"","url":"https://api.github.com/users/processing-js","html_url":"https://github.com/processing-js","followers_url":"https://api.github.com/users/processing-js/followers","following_url":"https://api.github.com/users/processing-js/following{/other_user}","gists_url":"https://api.github.com/users/processing-js/gists{/gist_id}","starred_url":"https://api.github.com/users/processing-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/processing-js/subscriptions","organizations_url":"https://api.github.com/users/processing-js/orgs","repos_url":"https://api.github.com/users/processing-js/repos","events_url":"https://api.github.com/users/processing-js/events{/privacy}","received_events_url":"https://api.github.com/users/processing-js/received_events","type":"Organization","site_admin":false},"repo":{"id":1282929,"name":"processing-js","full_name":"processing-js/processing-js","owner":{"login":"processing-js","id":1197580,"avatar_url":"https://avatars.githubusercontent.com/u/1197580?v=3","gravatar_id":"","url":"https://api.github.com/users/processing-js","html_url":"https://github.com/processing-js","followers_url":"https://api.github.com/users/processing-js/followers","following_url":"https://api.github.com/users/processing-js/following{/other_user}","gists_url":"https://api.github.com/users/processing-js/gists{/gist_id}","starred_url":"https://api.github.com/users/processing-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/processing-js/subscriptions","organizations_url":"https://api.github.com/users/processing-js/orgs","repos_url":"https://api.github.com/users/processing-js/repos","events_url":"https://api.github.com/users/processing-js/events{/privacy}","received_events_url":"https://api.github.com/users/processing-js/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/processing-js/processing-js","description":"A port of the Processing visualization language to JavaScript.","fork":true,"url":"https://api.github.com/repos/processing-js/processing-js","forks_url":"https://api.github.com/repos/processing-js/processing-js/forks","keys_url":"https://api.github.com/repos/processing-js/processing-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/processing-js/processing-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/processing-js/processing-js/teams","hooks_url":"https://api.github.com/repos/processing-js/processing-js/hooks","issue_events_url":"https://api.github.com/repos/processing-js/processing-js/issues/events{/number}","events_url":"https://api.github.com/repos/processing-js/processing-js/events","assignees_url":"https://api.github.com/repos/processing-js/processing-js/assignees{/user}","branches_url":"https://api.github.com/repos/processing-js/processing-js/branches{/branch}","tags_url":"https://api.github.com/repos/processing-js/processing-js/tags","blobs_url":"https://api.github.com/repos/processing-js/processing-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/processing-js/processing-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/processing-js/processing-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/processing-js/processing-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/processing-js/processing-js/statuses/{sha}","languages_url":"https://api.github.com/repos/processing-js/processing-js/languages","stargazers_url":"https://api.github.com/repos/processing-js/processing-js/stargazers","contributors_url":"https://api.github.com/repos/processing-js/processing-js/contributors","subscribers_url":"https://api.github.com/repos/processing-js/processing-js/subscribers","subscription_url":"https://api.github.com/repos/processing-js/processing-js/subscription","commits_url":"https://api.github.com/repos/processing-js/processing-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/processing-js/processing-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/processing-js/processing-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/processing-js/processing-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/processing-js/processing-js/contents/{+path}","compare_url":"https://api.github.com/repos/processing-js/processing-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/processing-js/processing-js/merges","archive_url":"https://api.github.com/repos/processing-js/processing-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/processing-js/processing-js/downloads","issues_url":"https://api.github.com/repos/processing-js/processing-js/issues{/number}","pulls_url":"https://api.github.com/repos/processing-js/processing-js/pulls{/number}","milestones_url":"https://api.github.com/repos/processing-js/processing-js/milestones{/number}","notifications_url":"https://api.github.com/repos/processing-js/processing-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/processing-js/processing-js/labels{/name}","releases_url":"https://api.github.com/repos/processing-js/processing-js/releases{/id}","created_at":"2011-01-22T21:07:41Z","updated_at":"2015-08-18T15:38:52Z","pushed_at":"2015-08-19T17:48:11Z","git_url":"git://github.com/processing-js/processing-js.git","ssh_url":"git@github.com:processing-js/processing-js.git","clone_url":"https://github.com/processing-js/processing-js.git","svn_url":"https://github.com/processing-js/processing-js","homepage":"http://processingjs.org/","size":44251,"stargazers_count":1936,"watchers_count":1936,"language":"Processing","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":361,"mirror_url":null,"open_issues_count":42,"forks":361,"open_issues":42,"watchers":1936,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/processing-js/processing-js/pulls/201"},"html":{"href":"https://github.com/processing-js/processing-js/pull/201"},"issue":{"href":"https://api.github.com/repos/processing-js/processing-js/issues/201"},"comments":{"href":"https://api.github.com/repos/processing-js/processing-js/issues/201/comments"},"review_comments":{"href":"https://api.github.com/repos/processing-js/processing-js/pulls/201/comments"},"review_comment":{"href":"https://api.github.com/repos/processing-js/processing-js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/processing-js/processing-js/pulls/201/commits"},"statuses":{"href":"https://api.github.com/repos/processing-js/processing-js/statuses/2fdb36b65d4d2e58e8726439b08ecb7df2aaf810"}}}}