Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.3K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Spherical coordinates to cartesian coordinates

Posted 4 years ago

Hey,

I was wondering if there is an easy way to convert the basis of a vector from spherical coordiantes to Cartesian coordinates. Here is what I mean:

Vector in spherical coordinates,

v=a er + b eth + c eph

(e_ are the unit vectors)

I only want to change the basis to cartesian, so it would look something like

v=(a*cos(ph)*sin(th)+b*cos(ph)*cos(th)-c*sin(ph)) i + (a*sin(th)*sin(ph) + b*cos(th)*sin(ph) + c*cos(ph)) j + (-b*sin(th)+a*cos(th)) k

I looked at CoordinateTransform function which transforms the given point in a given coordinate system to another system, but this is not exactly what I am looking for. The closest I found in VectorCalculus package was TransformedField function with the following call

TransformedField["Spherical"->"Cartesian", {a,b,c}, {r,th,ph}->{x,y,z}]

This works fine, but it also transforms the components.

So, is there any function, like TransformedField, which gives me

v={a*cos(ph)*sin(th)+b*cos(ph)*cos(th)-c*sin(ph),  (a*sin(th)*sin(ph) + b*cos(th)*sin(ph), c*cos(ph)) j + (-b*sin(th)+a*cos(th)}

?

Technically, I could multiply it with an appropriate matrix to get what I need, but it would be nice to have a function like the one above.

Thanks in advance.

POSTED BY: Yeso Alde
4 Replies

In my old Version 7 there is a command

CoordinatesToCartesian[{1, \[Pi]/2, \[Pi]/4}, Spherical]

I think this is pretty short and easy, but this seems to change the coordinates, not the base-vectors

POSTED BY: Hans Dolhaine
Posted 4 years ago

I found something but I am not sure if there is an easier way to achieve this.

trans=CoordinateTransformData["Spherical"->"Cartesian",OrthonormalBasisRotation",{r,th,ph}]//Transpose

trans.{a,b,c}
POSTED BY: Yeso Alde
Posted 4 years ago

Dear Hans,

Thank you. Yes, matrix multiplication is one way of doing it. But since Mathematica has really nice features such as TransformedField, CoordinateTransform which are pretty cool at automating this process, I was hoping there would be something for what I am looking for other than matrix multiplication and manually entering the transformation.

POSTED BY: Yeso Alde

My book says

er  = ex Sin[th]Cos[ph] + ey Sin[th]Sin[ph] + ez Cos[th]
eth= ex Cos[th]Cos[ph] + ey Cos[th]Sin[ph]- ez Sin[th]
eph= -ex Sin[ph] + ey Cos[ph]

That should give you the matrix to transform er, eth eph to ex, ey, ez

POSTED BY: Hans Dolhaine
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard