numpy.arctan2() in PythonThe element-wise arc tangent of arr1/arr2 is computed using the numpy.arctan2() function, which appropriately selects the quadrant. Selecting the quadrant ensures that the signed angle in radians between the rays commencing at the origin and going through the points (1, 0) and (x2, x1) is equal to arctan2(x1, x2). Syntax: Parameters :
Note: Return: Arc tangent of arr1/arr2 elementwise. The closed interval contains the values [-pi / 2, pi / 2]. Code #1: WorkingProgram Explanation: The arctangent of the ratios of corresponding items in two input arrays representing x and y coordinates is computed by this Python program using the NumPy module. Next, the values of arctan2 are transformed to degrees. The resultant arctan2 values are shown together with the initial x and y coordinates by the program. Here, the arctan2 function is used to illustrate how to use coordinate data to generate angles in a two-dimensional space, which is a very helpful use. Output: x-coordinates : [-1, 1, 1, -1] y-coordinates : [-1, -1, 1, 1] arctan2 values : [-135. -45. 45. 135.] Code #2: WorkingProgram Explanation: This Python program demonstrates how to use the NumPy library's arctan2() function. For some input arrays, such as zero, infinity, and negative zero, it computes the arctangent values. The outcomes for two distinct scenarios (a and b) are then displayed, showing how the arctan2() function responds to a range of input conditions and generates output that matches. Output: a: [0. 3.14159265 0.78539816] b: [ 1.57079633 -1.57079633] Next TopicNumpy argmin in python |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India