[Home]

rtp2xyz - Convert 3 dimensional spherical coordinates to rectangular coordinates

Overview

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

Input:

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).

Output:

X: x
Y: y
Z: z



Stack/Registers/Flags:

StackBeforeAfter
t-- (unchanged)
zphiz
ythetay
xrx

No registers and flags are used.

Example

To convert rectangular coordinates, (r, theta, phi) = (10, 30deg, 60deg) to rectangular coordinates,

				60 ENTER
				30 ENTER
				10 ENTER
				XEQ "->XYZ"
				X: 2.5
				Y: 4.33
				Z: 8.66
			

The Program

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

Variables

None


Programmed by Taku Yamanaka, February 9, 1992.