\cancel mode verify
! polar_map_inv_eqns.jnl
! 2/94 - internal routine used for creating inverse polar mappings
! These equations compute a long/lat point (polar_xdeg,polar_ydeg) given
! an x,y "page location" in a coordinate system where (0,0) should map
! to the pole and (-1,0), (+1,0), (0,-1), and (0,+1) map to 90 degree
! separated points on the equator (longitude influenced by "polar_rotation"

! Description: define the equations used for polar projections

! usage:   GO polar_map_inv_eqns output_grid

!   output grid		- the name of the grid created by projected_map_grid 

! Note:  "polar_rotation" must be defined external to this routine

! test arguments
query/ignore $1%<Use: GO polar_map_inv_eqns grid%

let/quiet polar_sumsq = x[g=$1]^2 + y[g=$1]^2
let/quiet polar_xrad = atan2(-1*x[g=$1],y[g=$1])*signgr
let/quiet polar_yrad = asin( (1-polar_sumsq)/(1+polar_sumsq) )*signgr
let/quiet rad2deg = 180 / 3.14159
let/quiet polar_xdeg180 = MOD(rad2deg*polar_xrad+polar_rotation+180+360, 360) - 180
let/quiet polar_xdeg = (polar_xdeg180 + 360)      ! all positive
let/quiet polar_ydeg = rad2deg * polar_yrad

set mode/last verify
