Re: Re: Re: coordinate transformation
- To: mathgroup at smc.vnet.net
- Subject: [mg13366] Re: [mg13308] Re: [mg13169] Re: [mg13117] coordinate transformation
- From: Sean Ross <seanross at worldnet.att.net>
- Date: Mon, 20 Jul 1998 02:50:19 -0400
- References: <199807171708.MAA00710@dragonfly.wolfram.com>
- Sender: owner-wri-mathgroup at wolfram.com
I hope this will shed a little light on the subject. In[1]:=Needs["Calculus`VectorAnalysis`"] In[2]:=CoordinatesToCartesian[{r,\[Theta],\[Phi]},Spherical] Out[2]:={r Cos[\[Phi]] Sin[\[Theta]],r Sin[\[Theta]] Sin[\[Phi]],r Cos[\[Theta]]} In[3]:=CoordinatesFromCartesian[{x,y,z},Spherical] Out[3]:={Sqrt[x^2 + y^2 + z^2], ArcCos[z/Sqrt[x^2 + y^2 + z^2]], ArcTan[x, y]} In[4]:=CrossProduct[{x1,y1,z1},{x2,y2,z2}] Out[4]:={-y2 z1+y1 z2,x2 z1-x1 z2,-x2 y1+x1 y2} In[5]:=CrossProduct[{r1,\[Theta]1,\[Phi]1},{r2,\[Theta]2,\[Phi]2},Spherical] Out[5]:={Sqrt[(-r1*r2*Cos[\[Theta]2]*Cos[\[Phi]1]*Sin[\[Theta]1] + r1*r2*Cos[\[Theta]1]*Cos[\[Phi]2]*Sin[\[Theta]2])^2 + (r1*r2*Cos[\[Theta]2]*Sin[\[Theta]1]*Sin[\[Phi]1] - r1*r2*Cos[\[Theta]1]*Sin[\[Theta]2]*Sin[\[Phi]2])^2 + (-r1*r2*Cos[\[Phi]2]*Sin[\[Theta]1]*Sin[\[Theta]2]*Sin[\[Phi]1] + r1*r2*Cos[\[Phi]1]*Sin[\[Theta]1]*Sin[\[Theta]2]*Sin[\[Phi]2])^2], ArcCos[(-r1*r2*Cos[\[Phi]2]*Sin[\[Theta]1]*Sin[\[Theta]2]*Sin[\[Phi]1] + r1*r2*Cos[\[Phi]1]*Sin[\[Theta]1]*Sin[\[Theta]2]*Sin[\[Phi]2])/ Sqrt[(-r1*r2*Cos[\[Theta]2]*Cos[\[Phi]1]*Sin[\[Theta]1] + r1*r2*Cos[\[Theta]1]*Cos[\[Phi]2]*Sin[\[Theta]2])^2 + (r1*r2*Cos[\[Theta]2]*Sin[\[Theta]1]*Sin[\[Phi]1] - r1*r2*Cos[\[Theta]1]*Sin[\[Theta]2]*Sin[\[Phi]2])^2 + (-r1*r2*Cos[\[Phi]2]*Sin[\[Theta]1]*Sin[\[Theta]2]*Sin[\[Phi]1] + r1*r2*Cos[\[Phi]1]*Sin[\[Theta]1]*Sin[\[Theta]2]*Sin[\[Phi]2])^2]], ArcTan[r1*r2*Cos[\[Theta]2]*Sin[\[Theta]1]*Sin[\[Phi]1] - r1*r2*Cos[\[Theta]1]*Sin[\[Theta]2]*Sin[\[Phi]2], -r1*r2*Cos[\[Theta]2]*Cos[\[Phi]1]*Sin[\[Theta]1] + r1*r2*Cos[\[Theta]1]*Cos[\[Phi]2]*Sin[\[Theta]2]]} Looking at the form of the last cross product, it seems clear that mathematica does not take non-cartesian cross products. What it does is to convert the vectors involved into cartesian vectors, take the cartesian cross product, then convert the result into the non cartesian coordinate system. This is a neat way to avoid a lot of difficulties, like having to know the coordinate metric, but it will never illustrate the problems involved. I also doubt its correctness. Here is why: Take any two cartesian vectors with one end at the origin and the other at some arbitrary point. We represent them by ordered triplets, {x1,y1,z1} and {x2,y2,z2}. Lets convert them into spherical coordinates: {Sqrt[x1^2+y1^2+z2^2],0,0} and {Sqrt[x2^2+y2^2+z2^2],0,0}. You ought to object at this point, because my theta and phi components are ZERO and this disagrees with the transformations given in mathematica. But think for a moment, if my vectors are centered at the origin, then they can only have a radial component. It seems as if I have lost some information about the vectors, but I haven't really. It is hidden in the cartesian representation of the radial unit vector, which are, {Sqrt[x1^2 + y1^2 + z1^2], ArcCos[z1/Sqrt[x1^2 + y1^2 + z1^2]], ArcTan[x1, y1]} and {Sqrt[x2^2 + y2^2 + z2^2], ArcCos[z2/Sqrt[x2^2 + y2^2 + z2^2]], ArcTan[x2, y2]}. Wow, you say, these are just what mathematica gives me! Yes, the transformations given in mathematica are for RADIAL VECTORS ONLY. What about the theta unit vectors or the phi unit vectors? They are not included, sad to say. Now take the two radial vectors up above and take their cross product in SPHERICAL coordinates. Since both of them are centered at the origin, the result will be centered at the origin as well and the result will also have no theta or phi components. What mathematica has returned to me in Out[5] is not the r, theta and phi COMPONENTS of the cross product at all, but the r, theta and phi VALUES of the cross product vector. It is one of these cases in which there is nothing wrong with the mathematica output as long as you realize what it is. The unwary might assume that mathematica was transforming vector components rather than coordinate points or that the cross product formula was valid for field vectors rather than length vectors. Now lets return to our two arbitrary cartesian vectors and say that they are centered on the point {x3,y3,z3}. Now, when I convert to Spherical Coordinates, the theta and phi components will, in general, not be zero and the cross product will also have theta and phi components. So, if I were to suggest a way to improve the VectorAnalysis package, I would have an optional argument for the location of the vector in the CoordinatesToCartesian and CoordinatesFromCartesian functions. I would also have the functions return the cartesian representation of the non-cartesian unit vectors as well as the components. In the cross product function, I would perform true, non-cartesian cross products, not the convert to cartesian then convert back. I would also emphasize by warning messages that for anything but radial length vectors, three pieces of information are not enough. You need six pieces of information: three vector components and three point coordinates. An example of this is an electric field vector E[{r,theta,phi}]={Er,Etheta,Ephi}. To totally specify this vector you need both the vector components, Er,Etheta,Ephi and you need the point coordinates, r,theta,phi . In cartesian coordinates, this can be neglected because the unit vectors are not position dependent. I would also adopt the standard that the notation of vector={x1,x2,x3} means that those are the vector COMPONENTS, not the coordinate VALUES of the point. This is often a point of confusion. The current vectoranalysis package assumes that we are only talking about coordinate VALUES, not vector COMPONENTS. The only case in which the components equal the coordinates are for... you guessed it: length vectors centered at the origin(radial vectors). This can be a great snare to the beginner taking E&M because he may want to transform a field vector in cartesian coordinates to a field vector in spherical. He naively uses your package and what he really has done is just transform the values of the point at which the vector exists not its components, but he has done it incorrectly because he probably would put in the values of the vector components into the function. I hope this helps. I am only illustrating broad concepts, not telling you exactly how to write your programs, nor writing a textbook on the subject of vector analysis.