Skip to content

Instantly share code, notes, and snippets.

Created February 23, 2016 03:41
Show Gist options
  • Select an option

  • Save anonymous/5611537fe1b1992add2b to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/5611537fe1b1992add2b to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/rawilawuba
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var p1 = {
x: 0,
y: 0
};
var p2 = {
x: 0,
y: 45
};
// angle in degrees
var angleDeg = Math.atan2(p2.y - p1.y, p2.x - p1.x) * 180 / Math.PI;
console.log(angleDeg);
</script>
<script id="jsbin-source-javascript" type="text/javascript">var p1 = {
x: 0,
y: 0
};
var p2 = {
x: 0,
y: 45
};
// angle in degrees
var angleDeg = Math.atan2(p2.y - p1.y, p2.x - p1.x) * 180 / Math.PI;
console.log(angleDeg);
</script></body>
</html>
var p1 = {
x: 0,
y: 0
};
var p2 = {
x: 0,
y: 45
};
// angle in degrees
var angleDeg = Math.atan2(p2.y - p1.y, p2.x - p1.x) * 180 / Math.PI;
console.log(angleDeg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment