Wednesday, 6 February 2008

Recentering a Spherical Coordinate Sytem

This is going to be unsightly...



The following Mathematica code:




Needs["VectorAnalysis`"]
Simplify@ CoordinatesFromCartesian[
CoordinatesToCartesian[{r, theta, phi}, Spherical]
+ CoordinatesToCartesian[{r0, theta0, phi0}, Spherical],
Spherical
]


gives the following output (doctored so that it looks nicer):



$$ r' = sqrt{r^2+2 r_0 r left(sin (theta ) sin
left(theta _0right) cos left(phi -phi
_0right)+cos (theta ) cos left(theta
_0right)right)+r_0^2} $$



$$ theta' = cos ^{-1}left(frac{r cos (theta )+r_0 cos
left(theta _0right)}{sqrt{r^2+2 r_0 r
left(sin (theta ) sin left(theta
_0right) cos left(phi -phi
_0right)+cos (theta ) cos left(theta
_0right)right)+r_0^2}}right) $$



$$ phi' = tan ^{-1}left(r sin (theta ) cos (phi
)+r_0 sin left(theta _0right) cos
left(phi _0right),r sin (theta ) sin
(phi )+r_0 sin left(theta _0right) sin
left(phi _0right)right) $$



In this last line, there is a two-argument variant of arctan, which is explained here, for example.

No comments:

Post a Comment