(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:
|
|||
05-05-2017, 06:12 PM
Post: #2
|
|||
|
|||
RE: (35s) Spherical coordinates <-> rectangular
(05-05-2017 05:51 PM)stephane Wrote: Find below two programs to convert from/to rectangular coordinates to/from spherical coordinates.Well, finally something to try on my HP 35s. Could you put a numerical example, and perhaps a graphic illustration, to check that everything works well? Thank you in advance, Pedro |
|||
05-05-2017, 06:34 PM
Post: #3
|
|||
|
|||
RE: (35s) Spherical coordinates <-> rectangular
To check that everything works well:
First, put your calculator in DEG mode, because the result depends on DEG or RAD. Example for rect2sph(10, 20, 30): Code:
should give the following values in the stack: T: [10,20,30] Z: 37.4166 (meters of distance) Y: 63.4349 (degrees of azimuth) X: 53.3008 (degrees of elevation) Example for sph2rect(5, 30°, 45°): Code:
should give the following values in the stack: T: [5,30,45] Z: 3.0619 (x value in meters) Y: 1.7678 (y value in meters) X: 3.5355 (z value in meters) Then, pressing XEQ S ENTER gives you again the initial spherical coordinates. |
|||
05-05-2017, 10:13 PM
Post: #4
|
|||
|
|||
RE: (35s) Spherical coordinates <-> rectangular
Thank you stepahne, Pedro
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)