Clicky

Fortran Wiki
atan2 (changes)

Skip the Navigation Links | Home Page | All Pages | Recently Revised | Authors | Feeds | Export |

Showing changes from revision #5 to #6: (追記) Added (追記ここまで) | (削除) Removed (削除ここまで) | (削除) Chan (削除ここまで)(追記) ged (追記ここまで)

Description

atan2(y, x) computes the arctangent of the complex number X+iY(削除) -\\\\-\\\\\\\\X (削除ここまで)(追記) X (追記ここまで) + i Y.

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 (x,y)(x,y) to polar coordinates (削除) (r,\\theta) (削除ここまで)(追記) (r,θ)(r,\theta) (追記ここまで):

(削除) \\begin{aligned} r &= \\sqrt{x^2 + y^2} \\\\ \\theta &= \\tan^{-1}(y / x) \\end{aligned} (削除ここまで)(追記) r =x 2+y 2 θ =tan 1(y/x) \begin{aligned} r &= \sqrt{x^2 + y^2} \\ \theta &= \tan^{-1}(y / x) \end{aligned} (追記ここまで)

Standard

FORTRAN 77 and later

Class

Elemental function

Syntax

result = atan2(y, x)

Arguments

  • 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.

Return value

The return value has the same type and kind type parameter as y. It is the principal value of the complex number X+iY(削除) (r,\\ (削除ここまで)(追記) X (追記ここまで)(削除) \\X (削除ここまで) + i Y. If x is nonzero, then it lies in the range (削除) -\\pi \\leq \\atan (x) \\leq \\pi (削除ここまで)(追記) πatan(x)π-\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 strictly positive, (削除) \\pi (削除ここまで)(追記) π\pi (追記ここまで) if x is negative and y is positive zero (or the processor does not handle signed zeros), and (削除) -\\pi (削除ここまで)(追記) π-\pi (追記ここまで) if x is negative and y is negative zero. Finally, if x is zero, then the magnitude of the result is (削除) \\pi/2 (削除ここまで)(追記) π/2\pi/2 (追記ここまで).

Example

program test_atan2
 real(4) :: x = 1.e0_4, y = 0.5e0_4
 x = atan2(y,x)
end program test_atan2

Note: In Return value, NNemec changed the first (削除) \\leq (削除ここまで)(追記) \leq (追記ここまで) to (削除) \\lt (削除ここまで)(追記) <\lt (追記ここまで). Joe Krahn reverted the edit, following the Fortran 2008 specs.

category: intrinsics

Revised on March 1, 2023 13:06:32 by Jason Blevins (23.245.217.121) (1712 characters / 0.0 pages)
Edit | Back in time (5 revisions) | Hide changes | History | Views: Print | TeX | Source | Linked from: Intrinsic procedures, Fortran 2008, atan

AltStyle によって変換されたページ (->オリジナル) /