Clicky
Showing changes from revision #4 to #5:
(追記) Added (追記ここまで) | (削除) Removed (削除ここまで) | (削除) Chan (削除ここまで)(追記) ged (追記ここまで)
atan2(y, x)
computes the arctangent of the complex number .
This function can be used to transform from Cartesian into polar coordinates and allows to determine the angle in the correct quadrant. To convert from Cartesian Coordinates to polar coordinates (r,\\theta)
:
\\begin{aligned}
r &= \\sqrt{x^2 + y^2} \\\\
\\theta &= \\tan^{-1}(y / x)
\\end{aligned}
FORTRAN 77 and later
result = atan2(y, x)
result = atan2(y, x)
(追記ここまで)
y
- The type shall be real
.x
- The type and kind type parameter shall be the same as y
. If y
is zero, then x
must be nonzero.The return value has the same type and kind type parameter as y
. It is the principal value of the complex number . If x
is nonzero, then it lies in the range -\\pi \\leq \\atan (x) \\leq \\pi
. The sign is positive if y
is positive. If y
is zero, then the return value is zero if x
is(削除) positive (削除ここまで)(追記) strictly (追記ここまで)(削除) and (削除ここまで)(追記) positive, (追記ここまで)\\pi
if x
is(削除) negative. (削除ここまで)(追記) negative (追記ここまで)(削除) Finally, (削除ここまで)(追記) and (追記ここまで)(削除) if (削除ここまで)(追記) y
(追記ここまで)(追記) is positive zero (or the processor does not handle signed zeros), and (追記ここまで)(追記) -\\pi
(追記ここまで)(追記) if (追記ここまで)(追記) x
(追記ここまで)(追記) is negative and (追記ここまで)(追記) y
(追記ここまで)(追記) is negative zero. Finally, if (追記ここまで)x
is zero, then the magnitude of the result is \\pi/2
.
program test_atan2
real(4) :: x = 1.e0_4, y = 0.5e0_4
x = atan2(y,x)
end program test_atan2
(削除) Note: In (削除ここまで)(追記) Note: (追記ここまで) (追記) In (追記ここまで) Return value,(削除) NNemec changed the first (追記) NNemec (追記ここまで)(追記) (追記ここまで)(追記) changed (追記ここまで)(追記) the (追記ここまで)(追記) first (追記ここまで)\\leq
to \\lt
. Joe Krahn reverted the edit, following F2008 specs. (削除ここまで)(削除) (追記) \\leq
(追記ここまで)(追記) to (追記ここまで)(追記) \\lt
(追記ここまで)(追記) . (追記ここまで)(追記) Joe Krahn (追記ここまで)(追記) reverted the edit, following the (追記ここまで)(追記) Fortran 2008 (追記ここまで)(追記) specs. (追記ここまで)