cart2polar Function

private function cart2polar(x, y) result(polar)

Convert from cartesian coordinates (in the x-y plane) to polar coordinates (radius,angle)

Arguments

Type IntentOptional Attributes Name
real(kind=rk) :: x

X coordinate

real(kind=rk) :: y

Y coordinate

Return Value real(kind=rk), (2)

Polar coordinates, radius (first entry) and angle (second entry)


Called by

proc~~cart2polar~~CalledByGraph proc~cart2polar cart2polar proc~tem_eval_miescatter_displz tem_eval_miescatter_displz proc~tem_eval_miescatter_displz->proc~cart2polar proc~tem_eval_miescatter_magnangular tem_eval_miescatter_magnangular proc~tem_eval_miescatter_magnangular->proc~cart2polar proc~tem_eval_miescatter_magnradial tem_eval_miescatter_magnradial proc~tem_eval_miescatter_magnradial->proc~cart2polar proc~tem_eval_miescatter_magnx tem_eval_miescatter_magnx proc~tem_eval_miescatter_magnx->proc~cart2polar proc~tem_eval_miescatter_magnx->proc~tem_eval_miescatter_magnangular proc~tem_eval_miescatter_magnx->proc~tem_eval_miescatter_magnradial proc~tem_eval_miescatter_magny tem_eval_miescatter_magny proc~tem_eval_miescatter_magny->proc~cart2polar proc~tem_eval_miescatter_magny->proc~tem_eval_miescatter_magnangular proc~tem_eval_miescatter_magny->proc~tem_eval_miescatter_magnradial proc~tem_spacetime_for_coord tem_spacetime_for_coord proc~tem_spacetime_for_coord->proc~tem_eval_miescatter_displz proc~tem_spacetime_for_coord->proc~tem_eval_miescatter_magnx proc~tem_spacetime_for_coord->proc~tem_eval_miescatter_magny proc~tem_spatial_for_coord tem_spatial_for_coord proc~tem_spatial_for_coord->proc~tem_eval_miescatter_displz proc~tem_spatial_for_coord->proc~tem_eval_miescatter_magnx proc~tem_spatial_for_coord->proc~tem_eval_miescatter_magny interface~tem_spacetime_for tem_spacetime_for interface~tem_spacetime_for->proc~tem_spacetime_for_coord interface~tem_spatial_for tem_spatial_for interface~tem_spatial_for->proc~tem_spatial_for_coord proc~tem_spacetime_for_stcoord tem_spacetime_for_stcoord proc~tem_spacetime_for_stcoord->proc~tem_spacetime_for_coord proc~tem_spacetime_scalar_for_index tem_spacetime_scalar_for_index proc~tem_spacetime_scalar_for_index->proc~tem_spacetime_for_coord proc~tem_spatial_scalar_for_index tem_spatial_scalar_for_index proc~tem_spatial_scalar_for_index->proc~tem_spatial_for_coord

Source Code

  function cart2polar(x,y) result(polar)
    ! --------------------------------------------------------------------------
    !> X coordinate
    real(kind=rk) :: x
    !> Y coordinate
    real(kind=rk) :: y
    !> Polar coordinates, radius (first entry) and angle (second entry)
    real(kind=rk) :: polar(2)
    ! --------------------------------------------------------------------------
    ! --------------------------------------------------------------------------

    polar(1) = sqrt(x*x + y*y)

    ! Atan2 is not defined when both coordinates are zero. To cover this
    ! situation correctly, we define the angle to be 0.
    if(polar(1) > epsilon(1.0_rk) ) then
      polar(2) = atan2(y,x)
    else
      polar(2) = 0.0_rk
    end if

  end function cart2polar