[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: sph2cart octave definition matches neither mathematical nor phsics

From: Nicholas Jankowski
Subject: Fwd: sph2cart octave definition matches neither mathematical nor phsics definitions
Date: Wed, 12 Feb 2020 06:53:37 -0500

(please keep the help list copied on all emails. message forwarded below.)

---------- Forwarded message ---------
From: J.A. (Hans) Piest <address@hidden>
Date: Wed, Feb 12, 2020 at 6:46 AM
Subject: sph2cart octave definition matches neither mathematical nor phsics definitions
To: <address@hidden>, <address@hidden>

Hi guys,

Finally I found out that the spherical coordinates in octave function sph2cart are defined as follows:

x = cos(phi) * cos(theta)
y = cos(phi) * sin(theta)
z = sin(phi)

In physics the coordinates are defined as follows:

x = sin(theta) * cos(phi)
y = sin(theta) * sin(phi)
z = cos(theta)

Mathematics is the same as in physics but with theta and phi interchanged:

x = sin(phi) * cos(theta)
y = sin(phi) * sin(theta)
z = cos(phi)

You can see from e.g. wikipedia => spherical coordinates that
both in mathematics and in physics the x,y,z axes are a righthanded oriented system,
which the default system both in physics and mathematics to use. Only theta and phi have
been interchanged.

E.g. for (theta,phi) = (30°,60°):

octave sph2crt formula     :  (x,y,z) = ( sqrt(3)/4 , 3/4       , sqrt(3)/2 )
octave sph2crt(pi/6, pi/3) :  (x,y,z) = ( 0.43301   , 0.25000   , 0.86603   )

physics formula            :  (x,y,z) = ( 1/4       , sqrt(3)/4 , sqrt(3)/2 )
mathematics formula        :  (x,y,z) = ( 3/4       , sqrt(3)/4 , 1/2       )

In the attachment I have compared the outputs of sph2crt(theta,phi,1)
with the outputs of the explicit formulas expressed above:

It show that the formulas for (x,y,z) for physics and mathematics give different results than
those for the explicit octave computation.

I think that it is very important that you give a clear picture of how sph2crt computes x,y,z.

I suggest that you simply put the formula

   x = cos(phi) * cos(theta)
   y = cos(phi) * sin(theta)
   z = sin(phi)

in the manual ... nobody can be confused anymore that way.


example publication:
CRDS of thin layers :

SV Morgenster bottom-up :
SV Morgenster top-down  :

8+ :

Attachment: sph2cart.csv
Description: Text Data

Attachment: sph2cart.ods
Description: application/vnd.oasis.opendocument.spreadsheet

reply via email to

[Prev in Thread] Current Thread [Next in Thread]