Guest User

Untitled

a guest
Feb 10th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. ClearAll[PolarStreamPlot]
  2.  
  3. SetAttributes[PolarStreamPlot, HoldAll];
  4.  
  5. Options[PolarStreamPlot]=Options[StreamPlot];
  6.  
  7. SyntaxInformation[PolarStreamPlot]={"ArgumentsPattern"->{{_,_},{_,_,_},{_,_,_},OptionsPattern[]},"LocalVariables"->{"Plot",{2,3}}} ;
  8.  
  9. PolarStreamPlot::badrange="Invalid range for `1`!";
  10.  
  11. PolarStreamPlot[
  12. fns_, {r_Symbol, rMin_, rMax_}, {t_Symbol, tMin_, tMax_}, opts:OptionsPattern[]] :=
  13. Module[{Fns, x, y, RF, TMin, TMax, mArcTan, RMax},
  14. If[rMin >= rMax,
  15. Message[PolarStreamPlot::badrange,"r"];
  16. Return[$Failed]
  17. ];
  18. If[tMin >= tMax || tMax - tMin > 2 Pi,
  19. Message[PolarStreamPlot::badrange,"\[Theta]"]
  20. Return[$Failed]
  21. ];
  22. TMin = Mod[tMin, 2 Pi, tMin];
  23. TMax = Mod[tMax, 2 Pi, tMin];
  24. If[TMax == TMin, TMax += 2 Pi];
  25. mArcTan[vars__] := Mod[ArcTan[vars], 2 Pi, TMin];
  26. Block[{r,t},
  27. Fns = TransformedField["Polar" -> "Cartesian", fns, {r, t} -> {x, y}] /. ArcTan -> mArcTan;
  28. ];
  29. RMax = rMax;
  30. StreamPlot[Fns, {x, -RMax, RMax}, {y, -RMax, RMax},
  31. RegionFunction ->
  32. Function[{x, y},
  33. Evaluate[mArcTan[x, y] <= TMax && rMin <= Sqrt[x^2 + y^2] <= rMax]], opts]
  34. ]
Advertisement
Add Comment
Please, Sign In to add comment