JavaScript atan2
Returns the arc tangent of y/x, with the resulting quadrant determined by the signs of y and x
1 2 3 4 56 7 8 9 10 | function atan2 (y, x) { // Returns the arc tangent of y/x, with the resulting quadrant determined by the signs of y and x // // version: 1008.1718 // discuss at: http://phpjs.org/functions/atan2 // + original by: Brett Zamir (http://brett-zamir.me) // * example 1: atan2(1, 1); // * returns 1: 0.7853981633974483 return Math.atan2(y, x); } |
Examples
Running
1 | atan2(1, 1); |
Should return
1 | 0.7853981633974483 |
Dependencies
No dependencies, you can use this function standalone.
Open syntax issues
php.js uses JsLint to help us keep our code consistent and prevent some common bugs.
Eventually we want all code to pass or at least take into consideration most fixes suggested by JsLint, following this JsLint configuration we’ve decided on.
Authors
Thanks to the following developers, you get to have atan2 goodness in JavaScript.
No comments yet. Be the first!
spread the word:
Use any PHP function in JavaScript
These kind folks have already donated: @HalfWinter, Paulo Freitas, Andros Peña Romo, Nitin Gupta, @nikosdion, Anonymous, Anonymous and Shawn Houser.
<your name here>