MathGroup Archive 1998

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

Search the Archive

Re: vectors in polar coordinates


  • To: mathgroup@smc.vnet.net
  • Subject: [mg11791] Re: vectors in polar coordinates
  • From: Paul Abbott <paul@physics.uwa.edu.au>
  • Date: Sat, 28 Mar 1998 00:25:26 -0500
  • Organization: University of Western Australia
  • References: <6fd6aa$6ck@smc.vnet.net>

Michael Milirud wrote:

> If I want to add 2 vectors of which I have a polar (cylindrical)
> representation I am forced to do something like
> 
> << Calculus`VectorAnalysis`
> SetCoordinates[Cylindrical]
> a={100, -115*Pi/180, 0}
> b={200, -30*Pi/180, 0}
> A=CoordinatesToCartesian[a, Cylindrical] B=CoordinatesToCartesian[b,
> Cylindrical] d=A+B
> D=CoordinatesFromCartesian[d, Cylindrical]
> 
> and that is a HECK longer to do then by hand. 

Actually, isn't that exactly how you WOULD do it by hand?

>There's got to be something simplier like:
> {100, -115*Pi/180, 0} + {200, -30*Pi/180, 0}

After loading the package

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

and setting the coordinate system

  In[2]:= SetCoordinates[Cylindrical]; 

you could use CirclePlus (a built-in infix operator) as follows:

  In[3]:= (a_) \[CirclePlus] (b_) := 
	  CoordinatesFromCartesian[CoordinatesToCartesian[a] + 
	    CoordinatesToCartesian[b]]

This expression will format nicely in a Notebook (especially if you are
using TraditionalForm for input and output).  Now you can use this to
add two vectors in whatever default coordinate system you are using,
e.g.,

  In[4]:= a = {100, -((115*Pi)/180), 0}; 
  In[5]:= b = {200, -((30*Pi)/180), 0}; 
  In[6]:= N[a \[CirclePlus] b]
  Out[6]= {231.271,-0.96892,0}

> Also how do I find a magnitude of a vector. The Abs[] doesn't support
> this. Sqrt[d[[1]]^2+d[[2]]^2+d[[3]]^2]

How about Sqrt[d.d].  Alternatively, you could try overloading Abs[].  A
better solutions is to use a DoubleBracketingBar:

  In[7]:= \[LeftDoubleBracketingBar] d_ \[RightDoubleBracketingBar]:=
Sqrt[d . d]
  In[8]:= \[LeftDoubleBracketingBar] {1, 1, 1}
\[RightDoubleBracketingBar]
  Out[8]= Sqrt[3]

Again, this input will format nicely in a Notebook.

Cheers,
	Paul 

____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia            Nedlands WA  6907       
mailto:paul@physics.uwa.edu.au  AUSTRALIA                            
http://www.pd.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________



  • Prev by Date: Re: FixedPoint and SameTest
  • Next by Date: Re: FixedPoint and SameTest
  • Prev by thread: Re: vectors in polar coordinates
  • Next by thread: Re: vectors in polar coordinates