(35S) Spherical coordinates <-> rectangular
|
05-05-2017, 05:51 PM
(This post was last modified: 06-15-2017 01:15 PM by Gene.)
Post: #1
|
|||
|
|||
(35S) Spherical coordinates <-> rectangular
Find below two programs to convert from/to rectangular coordinates to/from spherical coordinates.
The variables of the calculator are preserved. Only the stack is used. Two programs are provided: - rect2sph: XEQ S - sph2rect: XEQ R Cartesian coordinates are in the form (x, y, z) Spherical coordinates are in the form (r, theta, phi), where r is the radius/distance, theta is the azimuth, and phi is the elevation. Formula used are: x = r.cos(theta).cos(phi) y = r.sin(theta).cos(phi) z = r.sin(phi) r = sqrt(x²+y²+z²) theta = atan2(y, x) phi = atan2(z, sqrt(x²+y²)) Usage for rect2sph: Stack before: Z: x Y: y X: z Exec program: XEQ S Stack after: T: [x, y, z] Z: r Y: theta X: phi Usage for sph2rect: Stack before: Z: r Y: theta X: phi Exec program: XEQ R Stack after: T: [r, theta, phi] Z: x Y: y X: z Code for rect2sph: Code:
Code for sph2rect: Code:
|
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(35S) Spherical coordinates <-> rectangular - stephane - 05-05-2017 05:51 PM
RE: (35s) Spherical coordinates <-> rectangular - PedroLeiva - 05-05-2017, 06:12 PM
RE: (35s) Spherical coordinates <-> rectangular - stephane - 05-05-2017, 06:34 PM
RE: (35s) Spherical coordinates <-> rectangular - PedroLeiva - 05-05-2017, 10:13 PM
|
User(s) browsing this thread: 1 Guest(s)