cartesian_to_spherical(3f) - [M_units:TRIGONOMETRY] convert Cartesian coordinates to ISO polar coordinates (LICENSE:PD)
Synopsis
Description
Options
Results
Examples
Author
License
subroutine cartesian_to_spherical(x,y,z,radius,inclination,azimuth)
real,intent(in) :: x,y,z real,intent(out) :: radius,inclination,azimuth
Convert a cartesian point <X,Y,Z> to ISO 8000-2:2009 polar coordinates <radius, inclination, azimuth> with angles in radians using the formulas
radius=sqrt(x**2+y**2+z**2) inclination=acos(z/radius) azimuth=atan2(y,x)
X The distance along the x-axis Y The distance along the y-axis Z The distance along the z-axis
RADIUS The radial distance from the origin (O) to the point (P) INCLINATION The zenith angle in radians between the zenith reference direction (z-axis) and the line OP AZIMUTH The azimuth angle in radians between the azimuth 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_spherical use M_units, only : cartesian_to_spherical implicit none real :: x,y,z real :: r,i,a integer :: ios INFINITE: do read(*,*,iostat=ios) x, y, z if(ios.ne.0)exit INFINITE call cartesian_to_spherical(x,y,z,r,i,a) write(*,*)x=,x, y=,y, z=,z,radius=,r,inclination=,i,azimuth=,a enddo INFINITE end program demo_cartesian_to_spherical
John S. Urban
Public Domain
Nemo Release 3.1 | cartesian_to_spherical (3) | February 23, 2025 |