Created
June 7, 2020 07:34
-
-
Save netsi1964/5a719bc9e993cce6cd40b1e12f2507d1 to your computer and use it in GitHub Desktop.
Some useful extenstions to javascript
This file contains 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
Object.prototype.rad = (deg) => Math.PI/180 * deg; | |
Object.prototype.deg = (rad) => 180/Math.PI * rad; | |
Object.prototype.getAngle = (point1, point2) => Math.atan2(point1.y - point2.y, point1.x - point2.x); | |
Object.prototype.getDistance = (point1, point2) => Math.sqrt(Math.pow(point1.x-point2.x, 2) + Math.pow(point1.y-point2.y, 2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment