nlcpy.arctan2
- nlcpy.arctan2 = <ufunc 'nlcpy_arctan2'>
Computes the element-wise inverse tangent of x1/x2 choosing the quadrant correctly.
This function is not defined for complex-valued arguments; for the so-called argument of complex values, use angle.
- Parameters
- x1, x2array_like
The values of x1 are y-coordinates. Also, The values of *x2 are x-coordinates. *x1 and x2 must be real. If
x1.shape != x2.shape
, they must be broadcastable to a common shape (which becomes the shape of the output).- outndarray or None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
- wherearray_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized.- **kwargs
For other keyword-only arguments, see the section Optional Keyword Arguments.
- Returns
- anglendarray
Array of angles in radians, in the range
[-pi, pi]
. If x1 and x2 are both scalars, this function returns the result as a 0-dimension ndarray.
See also
Examples
Consider four points in different quadrants:
>>> import nlcpy as vp >>> x = vp.array([-1, +1, +1, -1]) >>> y = vp.array([-1, -1, +1, +1]) >>> vp.arctan2(y, x) * 180 / vp.pi array([-135., -45., 45., 135.])
Note the order of the parameters.
arctan2()
is defined also when x2 = 0 and at several other special points, obtaining values in the range[-pi, pi]
:>>> vp.arctan2([1., -1.], [0., 0.]) array([ 1.57079633, -1.57079633]) >>> vp.arctan2([0., 0., vp.inf], [+0., -0., vp.inf]) array([0. , 3.14159265, 0.78539816])