cartesian_to_polar(3f) - [M_units:TRIGONOMETRY] convert Cartesian coordinates to polar coordinates (LICENSE:PD)
Synopsis
Description
Options
Results
Examples
Author
License
subroutine cartesian_to_polar(x,y,radius,inclination)
real,intent(in) :: y,z real,intent(out) :: radius,inclination
Convert a cartesian point <X,Y,Z> to polar coordinates <radius, inclination> with angles in radians using the formulas
radius=sqrt(x**2+y**2) inclination=atan2(y,x)
X The distance along the x-axis Y The distance along the y-axis
RADIUS The radial distance from the origin (O) to the point (P) INCLINATION The inclination angle in radians between the inclination reference direction (x-axis) and the orthogonal projection of the line OP of the reference plane (x-y plane).
examples of usage
program demo_cartesian_to_polar use M_units, only : cartesian_to_polar implicit none real :: x,y real :: r,i integer :: ios INFINITE: do read(*,*,iostat=ios) x, y if(ios.ne.0)exit INFINITE call cartesian_to_polar(x,y,r,i) write(*,*)x=,x, y=,y,radius=,r,inclination=,i enddo INFINITE end program demo_cartesian_to_polar
John S. Urban
Public Domain
cartesian_to_polar (3) | March 11, 2021 |