README.md (1915B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # atan2 22 23 > Compute the angle in the plane (in radians) between the positive x-axis and the ray from `(0,0)` to the point `(x,y)`. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var atan2 = require( '@stdlib/math/base/special/atan2' ); 31 ``` 32 33 #### atan2( y, x ) 34 35 Computes the angle in the plane (in radians) between the positive x-axis and the ray from `(0,0)` to the point `(x,y)`. 36 37 ```javascript 38 var v = atan2( 2.0, 2.0 ); // => atan(1.0) 39 // returns ~0.785 40 41 v = atan2( 6.0, 2.0 ); // => atan(3.0) 42 // returns ~1.249 43 44 v = atan2( -1.0, -1.0 ); // => atan(1.0) - π 45 // returns ~-2.356 46 47 v = atan2( 3.0, 0.0 ); // => π/2 48 // returns ~1.571 49 50 v = atan2( -2.0, 0.0 ); // => -π/2 51 // returns ~-1.571 52 53 v = atan2( 0.0, 0.0 ); 54 // returns 0.0 55 56 v = atan2( 3.0, NaN ); 57 // returns NaN 58 ``` 59 60 </section> 61 62 <!-- /.usage --> 63 64 <section class="examples"> 65 66 ## Examples 67 68 <!-- eslint no-undef: "error" --> 69 70 ```javascript 71 var randu = require( '@stdlib/random/base/randu' ); 72 var atan2 = require( '@stdlib/math/base/special/atan2' ); 73 74 var y; 75 var x; 76 var i; 77 78 for ( i = 0; i < 100; i++ ) { 79 y = randu() * 100.0; 80 x = randu() * 100.0; 81 console.log( 'y: %d, \t x: %d, \t atan2(y,x): %d', y.toFixed( 4 ), x.toFixed( 4 ), atan2( y, x ).toFixed( 4 ) ); 82 } 83 ``` 84 85 </section> 86 87 <!-- /.examples --> 88 89 <section class="links"> 90 91 </section> 92 93 <!-- /.links -->