[Home]

xyz2rtp - Convert 3 dimensional rectangular coordinates to spherical coordinates

Overview

This program converts 3 dimensional rectangular coordinates, (x, y, z), to spherical coordiantes, (r, theta, phi).

Input:

X: x
Y: y
Z: z

Output:

X: r (radius)
Y: theta (polar angle)
Z: phi (azumuthal angle)

The angles are given in the units set by the current angular mode (degree/radian/gradian).

Stack/Registers/Flags:

StackBeforeAfter
t-- (unchanged)
zzphi
yytheta
xxr

No registers and flags are used.

Example

To convert rectangular coordinates, (x,y,z) = (3, 4, 6.25) to spherical coordinates,

				6.25 ENTER
				4 ENTER
				3 ENTER
				XEQ "->RTP"
				X: 8.00   (r:     radius)
				Y: 38.66   (theta: polar angle)
				Z: 53.13   (phi:   azumuth angle)
				(if in degree mode)
			

The Program

LINE    KEYS
00   { 13-Byte Prgm }  
01   LBL "->RTP"       ;
02   ->POL             ; (x,y,z,t) -> (r_xy, phi, z, t)
03   roll up           ;  -> (t, r_xy, phi, z)
04   X<> ST T          ;  -> (z, r_xy, phi, t); Key in X<>, .(period), ST T
05   ->POL             ;  -> (r, theta, phi, t)
06   END               ;

Variables

None


Programmed by Taku Yamanaka, February 9, 1992.