MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Converting between Spherical and Cartesian coordinates


Alain,

Seems that it does simplify if Pphi (as a latitude) ranges
from -Pi/2 to Pi/2 and if you don't allow equalities in coordinate
ranges :

In[1]:=<<Calculus`VectorAnalysis`

In[2]:=SetCoordinates[Spherical]
Out[2]=Spherical[Rr,Ttheta,Pphi]

In[3]:=
Unprotect[CoordinateRanges];
CoordinateRanges[ ]={0<Rr<Infinity, 0<Ttheta<Pi, -Pi/2<Pphi<Pi/2};
Protect[CoordinateRanges];

In[6]:=sph=CoordinatesFromCartesian[{x,y,z}]
Out[6]={Sqrt[x^2 + y^2 + z^2], ArcCos[z/Sqrt[x^2 + y^2 + z^2]],
ArcTan[x, y]}

In[7]:=
car=sph /. Thread[{x,y,z} -> CoordinatesToCartesian[{Rr,Ttheta,Pphi}]]
Out[7]=
{Sqrt[Rr^2*Cos[Ttheta]^2 + Rr^2*Cos[Pphi]^2*Sin[Ttheta]^2 +
Rr^2*Sin[Pphi]^2*Sin[Ttheta]^2],
ArcCos[(Rr*Cos[Ttheta])/Sqrt[Rr^2*Cos[Ttheta]^2 +
Rr^2*Cos[Pphi]^2*Sin[Ttheta]^2 +
Rr^2*Sin[Pphi]^2*Sin[Ttheta]^2]],
ArcTan[Rr*Cos[Pphi]*Sin[Ttheta], Rr*Sin[Pphi]*Sin[Ttheta]]}

In[8]:=car // Simplify[#,CoordinateRanges[ ]]&
Out[8]={Rr,Ttheta,Pphi}


hth


Valeri


  • Prev by Date: concatenating files, slowdown
  • Next by Date: Re: any updates to Mathematica control system professional application?
  • Previous by thread: Converting between Spherical and Cartesian coordinates
  • Next by thread: Re: Converting between Spherical and Cartesian coordinates