Re: Question:Polar Field Plot
- To: mathgroup at smc.vnet.net
- Subject: [mg21621] Re: [mg21589] Question:Polar Field Plot
- From: Hartmut Wolf <hwolf at debis.com>
- Date: Tue, 18 Jan 2000 02:35:11 -0500 (EST)
- Organization: debis Systemhaus
- References: <200001160856.DAA10817@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
ZEE MEANT NG schrieb:
>
> I am trying to plot a 2D vector field. Equations which i have are in
> polar form ie r and theta.
> r^2= x^2+y^2
> Er=f(r,Theta)
> Ep=g(r,Theta)
>
> I have changed them to cartesian form ie Ex, Ey .
> and put Theta= arctan[y/x]
> My plot covers the region {x,-1,1} and {y-1,1}
>
> Question 1:
> The values of theta produced by mathematica are
> -90<Theta<90 degree but what i required is theta which gives the
> value from 0 to 360 degree.
> I have used the if statement as follows but it does not work.
> If[x >= 0, [Theta] = ArcTan[y/x], [Theta] = ArcTan[y/x] + \[Pi]];
> PlotVectorField[{Ex1, Ey1}, {x, - R, R},
> {y, - R, R }]
>
> Question 2:
> Using the built-in function to plot the vector field, it plots all
> the field for the entire region. How do i set some constraints so
> that it only plots at the desired region (eg. plot where x^2+y^2 < R)
> ?
>
> I am having the same problem in the contour plot as well.
hi Zee,
To question 1: simply use ArcTan[x,y] which regards the quandrant where
{x,y} lies.
To question 2: a simple method would be to just suppress unwanted
output, e.g.:
In[1]:= << Graphics`PlotField`
In[6]:= PlotVectorField[{-y, x},
{x, -1, 1}, {y, -1, 1}]
and then
In[9]:=
Show[%6 /. Arrow[{x_, y_}, __] /; x^2 + y^2 > 1.1 -> Sequence[] ]
look, that I didn't write x^2 + y^2 > 1 because this gives a somewhat
ugly appearance (on obvious grounds as you will see)
Of course one could try to write a function PlotSphericalVectorField
but it might be difficult to get the sampling points right at nearly
constant density (perhaps with the exclusion of a hexgonal pattern, or
any of Escher's for that matter).
kind regards, Hartmut