DirectionFieldPlot[]
- To: mathgroup at christensen.cybernetics.net
- Subject: [mg411] DirectionFieldPlot[]
- From: Xah Y Lee <xyl10060 at fhda.edu>
- Date: Mon, 16 Jan 1995 21:17:30 -0800 (PST)
MathGroupers,
I am taking my first Differential Equations course and encountered Direction
Field Plot.
I wrote a mma program to do the plot. Included below.
Execute the following and you'll see the plot.
---------------------------------
(*variables used*)
Clear[xMin, xMax, xStep, yMin, yMax, yStep, ll, fun]
Clear[gridList, slopeList, destList, GP1, g1]
{xMin,xMax,xStep} = {-3,3,.2}; (*specify the grid points*)
{yMin,yMax,yStep} = {-3,3,.2};
ll = 1 (*ll = line length*); (* specify the slop length to be drawn*)
fun = (#1^2-#2)&; (* specify the function to be ploted*)
gridList = N@Flatten[ Table[{x,y},
{x,xMin,xMax,xStep},{y,yMin,yMax,yStep}], 1];
slopeList = fun[Sequence@@#]& /@ gridList;
destList = gridList + ll * ( {Cos@#,Sin@#}& /@ (ArcTan /@ slopeList) );
GP1 = N @ Line /@ Transpose[{gridList, destList}];
g1 = Graphics[{Hue[0.00], GP1 }, Axes->True, AspectRatio->Automatic];
Show[ g1 ]
(*GP stand for GraphicPrimitive. g1 is an graphic object that can be used
with Show[]*)
---------------------------------
I am going to modify this into a package that contain a function
DirectionFieldPlot[] that can be used as easily as Plot, with online
documentations. I may upload this to MathSource sometimes in the future.
I wrote another program that do Trochoid animations. MathSource item number:
0207-234.
Xah Lee xyl10060 at tiptoe.fhda.edu 74631.731 at compuserve.com
A stud at Foothill College.
Mountain View, CA
Quote of the day: Can you tell me how to get to Sesame Street?