Re: Vector Field
- To: mathgroup at smc.vnet.net
- Subject: [mg16332] Re: Vector Field
- From: adam.smith at hillsdale.edu
- Date: Sun, 7 Mar 1999 01:05:50 -0500
- Organization: Deja News - The Leader in Internet Discussion
- References: <7bg1g5$5l8@smc.vnet.net> <7bntqq$diq@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
I seem to be having trouble posting things. This is about my third try. Hopefully it worked. Below, Jens provided an easy way to do this. However, as I read your message, you just want a set of vectors which "sits" on the sphere and is normal to it. I have a solution which does just this. First, note that the equation for a sphere is f = x^2 + y^2 + z^2. The gradient of this produces normals to this curve. In this case the gradient of f = {2 x, 2 y, 2 z}. I dropped the constant factor of two - it makes the display "nicer". Then the task is to great a list of a vector {x,y,z} at specific points {x,y,z} corresponding to the sphere you chose. This is done in the normals = Flatten[Table....]command. Then this list is plotted. Here is the Mathematica input I used: <<Graphics`PlotField3D` sphere = ParametricPlot3D[{Sin[x]*Cos[y],Sin[x]*Sin[y],Cos[x]},{x,0,Pi}, {y,0,2*Pi},DisplayFunction->Identity] normals = Flatten[ Table[ {{Sin[u]*Cos[v],Sin[u]*Sin[v],Cos[u]}, {Sin[u]*Cos[v],Sin[u]*Sin[v],Cos[u]}}, {u,0,Pi, Pi/4},{v,0,2 Pi, Pi/4}],1]; vec = ListPlotVectorField3D[normals,Axes->True,VectorHeads->True, DisplayFunction->Identity] Show[{sphere,vec},DisplayFunction->$DisplayFunction] You can adjust the limits in the table to suit your preferences. I hope that this is helpful. Adam Smith In article <7bntqq$diq at smc.vnet.net>, Jens-Peer Kuska <kuska at informatik.uni-leipzig.de> wrote: > Hi Luke, > > why to use Photoshop to overlay the images ? The combination is easy: > > field = PlotGradientField3D[1/(1 + x^2 + y^2 + z^2), {x, -1.2, 1.2}, > {y, 0, 1.2}, {z, -1.2, 1.2}, VectorHeads -> > True,DisplayFunction->Identity] > > sph = ParametricPlot3D[{Cos[phi]*Sin[th], Sin[phi]*Sin[th], Cos[th]}, > {phi, 0, Pi}, {th, 0, Pi},DisplayFunction->Identity] > > Show[{sph, field},DisplayFunction->$DisplayFunction] > > Hope that helps > Jens > > Luke wrote: > > > > I am trying to create a picture of a sphere with Normal vectors on the > > surface to demonstrate the Divergence Theorum. I am quite new to Mathematica > > and I was wondering if it could be done. > > > > I have created the sphere using: > > > > ParametricPlot3D[{Sin[x]*Cos[y],Sin[x]*Sin[y],Cos[x]},{x,0,Pi},{y,0,2*Pi}] > > > > I am hoping to be able to use PlotVectorField3D to create a vector field and > > overlay in on the image using Photoshop where I could remove the vector > > which should not be in view. I'm not sure how to plot the field desired. > > > > Anyone have any suggestions? > > > > Luke > > -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own