v?atan2
Compute the element-wise arctangent of src1/src2. src1, src2, and the arctangent are all vectors.
Interface Definition
C interface:
void vsatan2(const int len, const float* src1, const float* src2, float* dst);
void vdatan2(const int len, const double* src1, const double* src2, double* dst);
Fortran interface:
CALL VSATAN2(LEN, SRC1, SRC2, DST);
CALL VDATAN2(LEN, SRC1, SRC2, DST);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
len |
Integer |
Number of elements in the input vector. If len ≤ 0, the system displays a message indicating that the value of len is invalid. |
Input |
src1 |
|
Input vector src1 with length len. If the pointer is null, the system prompts a null pointer error. |
Input |
src2 |
|
Input vector src2 with length len. If the pointer is null, the system prompts a null pointer error. |
Input |
dst |
|
Output vector dst with length len. If the pointer is null, the system prompts a null pointer error. |
Output |
Return Value
- An azimuth from the origin to the point (x, y) is returned for each operation value atan2(y, x), that is, the included angle with reference to the x-axis. The unit of the return value is radian, and the value range is (-π, +π].
- For special values, see the following table.
Input Value 1 (src1)
Input Value 2 (src2)
Output Value (dst)
±0
-0
±π
±0
+0
±0
±∞
finite
±π/2
±∞
-∞
±3π/4
±∞
+∞
±π/4
<0
±0
-π/2
>0
±0
-π/2
+finite
-inf
+π
-finite
-inf
-π
+finite
+inf
+0
-finite
+inf
-0
nan
any
nan
any
nan
nan
Dependencies
C: "kvml.h"
Fortran: "kvml.f03"
Examples
C interface:
int i, len = 4;
float src1[len] = {0.0f, 1.0f, -inf, inf};
float src2[len] = {0.0f, 2.0f, inf, nan};
float* dst = (float*)malloc(sizeof(float) * len);
if (dst == NULL) {
printf("Malloc Failed!\n");
return 0;
}
vsatan2(len, src1, src2, dst);
/**
* Output dst:
* 0.0 0.463647603988647 -0.785398185253143 nan
*
*/
Fortran interface:
INTEGER :: LEN = 4
REAL(4) SRC1(4)
REAL(4) SRC2(4)
REAL(4) DST(4)
DATA SRC1 /1.2, 2.5, -2.4, 3.6/
DATA SRC2 /8.6, -2.5, -12.4, 32.6/
CALL VSATAN2(LEN, SRC1, SRC2, DST)
!
! OUTPUT DST:
! 0.138639733, 2.35619450, -2.95040822, 0.109983824
!