Skip to content

Instantly share code, notes, and snippets.

@jshaw
Forked from conorbuck/angle-between-points.js
Created March 11, 2022 23:21
Show Gist options
  • Save jshaw/b0759070bb7a2d873d33435092e9f8bd to your computer and use it in GitHub Desktop.
Save jshaw/b0759070bb7a2d873d33435092e9f8bd to your computer and use it in GitHub Desktop.

Revisions

  1. @conorbuck conorbuck revised this gist May 5, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions angle-between-points.js
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,8 @@ var p2 = {
    y: 40
    };

    // angle in radians
    var angleRadians = Math.atan2(p2.y - p1.y, p2.x - p1.x);

    // angle in degrees
    var angleDeg = Math.atan2(p2.y - p1.y, p2.x - p1.x) * 180 / Math.PI;
  2. @conorbuck conorbuck created this gist May 5, 2012.
    13 changes: 13 additions & 0 deletions angle-between-points.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    var p1 = {
    x: 20,
    y: 20
    };

    var p2 = {
    x: 40,
    y: 40
    };

    var angleRadians = Math.atan2(p2.y - p1.y, p2.x - p1.x);

    var angleDeg = Math.atan2(p2.y - p1.y, p2.x - p1.x) * 180 / Math.PI;