Cartesian and spherical coordinates |
This page deals with transformations between cartesian and spherical coordinates, for positions and velocity coordinates
Each time, considerations about units used to express the coordinates are taken into account.
As I couldn't find the formulae for the velocities on the web, I wrote this page.
This has been implemented in jephem.astro.Body.sphereToCart() and cartToSphere() .
|
We know ρ, θ, φ the spherical coordinates of M, and their derivates .
Positions
Conversion for positions can be easily found from figure 1:
with
(formulae 1).
About units :
Before applying this formula, θand φ must be converted to radians.
X, Y, Z are expressed in the same unit as ρ.
Velocities
Derivating formulae 1 with respect to time, one obtains :
(formulae 2).
About units :
Before applying this formula, θ and φ must be converted to radians.
The unit of depends on the units of and , which must be homogenous before applying the formula. For example, if is in m/s and in rad/day, the formula can't be applied.
The easiest way to handle that is to convert the units before applying the formula. In JEphem, the choice was made to convert in au/day and in rad/day. So are obtained in au/day.
Positions
From formulae 1, we get :
About units :
Using these formulae,
ρ has the same unit as X, Y and Z;
θ can be computed with no ambiguity because arcsin
return a angle between -π/2 and π/2 ; θ is expressed in radians.
To compute φ, a method was written : tig.maths.Maths.atan3(double x, double y)
, which returns a number between 0 and 2π ; φ is expressed in radians.
Velocities
We know the X, Y, Z, the coordinates of M, and their derivates
About units :
We suppose that X, Y, Z are expressed in the same unit, and that
are also expressed in the same unit.
We also suppose that metric unit of
equals to the unit of X, Y, Z.
This must be checked before using the following formulae.
Formulae 2 can be expressed as :
(formulae 3).
From formulae 1, we get :
Using these expressions, formulae 2 becomes
This is a system of 3 equations with 3 unknowns ; solving this system with usual methods leads to the searched results :
About units :
will be expressed in the same unit as
;
The unit of
depends on the unit of
. The dimension is
. The angular unit is dimensionless, so it is in radians; the time utnit depends on the time unit of
.
Ex : if
are in ua/day, the unit will be rad/day ; if it's km/s, it will be rad/s etc...
To do : check if the stuffs about units are true. Check also the last formula.