atan2 function
dynamic
atan2(
- dynamic a,
- dynamic b
Returns the angle in radians between the positive x-axis and the vector.
The result is in the range -PI and PI.
If b is positive, this is the same as atan(a/b).
The result is negative when a is negative (including when a is the double -0.0).
If a is equal to zero, the vector (b,a) is considered parallel to the x-axis,
even if b is also equal to zero. The sign of b determines the direction
of the vector along the x-axis.
Returns NaN if either argument is NaN.
Example:
print(atan2(3, 4)); // Output: 0.6435011087932843868028
// atan(3 / 4) = 0.6435011087932843868028
Example 2:
print(atan2(Complex(1, 2), Complex(3, 4))); // Output: 1.3389725222944935 + 0.4023594781085251i
Example 3:
print(atan2(Matrix.identity(2), Matrix.identity(2))); // Output: [[1.0, 0.0], [0.0, 1.0]]
Implementation
dynamic atan2(dynamic a, dynamic b) {
if (a is Matrix && b is Matrix) {
return MatrixFunctions(a).atan2(b);
} else {
return Complex(a).atan2(Complex(b));
}
}