This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Converts degrees to radians. | |
* | |
* @param degrees | |
*/ | |
function degreesToRadians(degrees) { | |
return degrees * Math.PI / 180; | |
} | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function circPoint(angle, center, radius) { | |
return { | |
x: center.x + radius * Math.cos(degreesToRadians(angle)), | |
y: center.y + radius * Math.sin(degreesToRadians(angle)) | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function lineDistance(p1, p2) { | |
var xs = 0; | |
var ys = 0; | |
xs = p2.x - p1.x; | |
xs = xs * xs; | |
ys = p2.y - p1.y; | |
ys = ys * ys; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function angleFromPoints(p1, p2) { | |
return Math.atan2(p2.y - p1.y, p2.x - p1.x); | |
} |