Compute the Cartesian coordinates of a points , starting from the spherical, or optionally elliptical, polar coordinates of the point relative to a point
FT 28.11.2022
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
double precision, | intent(in) | :: | r |
coordinate of the point , relative to |
||
double precision, | intent(in) | :: | theta |
coordinate (colatitude) of the point , relative to |
||
double precision, | intent(in) | :: | phi |
coordinate (azimuth) of the point , relative to |
||
double precision, | intent(in) | :: | xo |
coordinate of the point |
||
double precision, | intent(in) | :: | yo |
coordinate of the point |
||
double precision, | intent(in) | :: | zo |
coordinate of the point |
||
double precision, | intent(out) | :: | x |
coordinate of the point |
||
double precision, | intent(out) | :: | y |
coordinate of the point |
||
double precision, | intent(out) | :: | z |
coordinate of the point |
||
double precision, | intent(in), | optional | :: | a_y |
Ratio between the y and x semiaxes of the ellipse |
|
double precision, | intent(in), | optional | :: | a_z |
Ratio between the z and x semiaxes of the ellipse |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
double precision, | public | :: | ay | ||||
double precision, | public | :: | az |
PURE SUBROUTINE cartesian_from_spherical &
( r, theta, phi, xo, yo, zo, x, y, z, a_y, a_z )
!****************************************************************
!
!# Compute the Cartesian coordinates of a points \(p\),
! starting from the spherical, or optionally elliptical, polar
! coordinates of the point \(p\) relative to a point \(O\)
!
! FT 28.11.2022
!
!****************************************************************
USE constants, ONLY: pi
IMPLICIT NONE
DOUBLE PRECISION, INTENT(IN):: r
!! \(r\) coordinate of the point \(p\), relative to \(O\)
DOUBLE PRECISION, INTENT(IN):: theta
!! \(\theta\) coordinate (colatitude) of the point \(p\), relative to \(O\)
DOUBLE PRECISION, INTENT(IN):: phi
!! \(\phi\) coordinate (azimuth) of the point \(p\), relative to \(O\)
DOUBLE PRECISION, INTENT(IN):: xo
!! \(x\) coordinate of the point \(O\)
DOUBLE PRECISION, INTENT(IN):: yo
!! \(y\) coordinate of the point \(O\)
DOUBLE PRECISION, INTENT(IN):: zo
!! \(z\) coordinate of the point \(O\)
DOUBLE PRECISION, INTENT(OUT):: x
!! \(x\) coordinate of the point \(p\)
DOUBLE PRECISION, INTENT(OUT):: y
!! \(y\) coordinate of the point \(p\)
DOUBLE PRECISION, INTENT(OUT):: z
!! \(z\) coordinate of the point \(p\)
DOUBLE PRECISION, INTENT(IN), OPTIONAL:: a_y
!! Ratio between the y and x semiaxes of the ellipse
DOUBLE PRECISION, INTENT(IN), OPTIONAL:: a_z
!! Ratio between the z and x semiaxes of the ellipse
DOUBLE PRECISION:: ay, az
IF(PRESENT(a_y))THEN
ay= a_y
ELSE
ay= one
ENDIF
IF(PRESENT(a_z))THEN
az= a_z
ELSE
az= one
ENDIF
x= xo + r*SIN(theta)*COS(phi)
y= yo + ay*r*SIN(theta)*SIN(phi)
z= zo + az*r*COS(theta)
END SUBROUTINE cartesian_from_spherical