Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ClearAll[PolarStreamPlot]
- SetAttributes[PolarStreamPlot, HoldAll];
- Options[PolarStreamPlot]=Options[StreamPlot];
- SyntaxInformation[PolarStreamPlot]={"ArgumentsPattern"->{{_,_},{_,_,_},{_,_,_},OptionsPattern[]},"LocalVariables"->{"Plot",{2,3}}} ;
- PolarStreamPlot::badrange="Invalid range for `1`!";
- PolarStreamPlot[
- fns_, {r_Symbol, rMin_, rMax_}, {t_Symbol, tMin_, tMax_}, opts:OptionsPattern[]] :=
- Module[{Fns, x, y, RF, TMin, TMax, mArcTan, RMax},
- If[rMin >= rMax,
- Message[PolarStreamPlot::badrange,"r"];
- Return[$Failed]
- ];
- If[tMin >= tMax || tMax - tMin > 2 Pi,
- Message[PolarStreamPlot::badrange,"\[Theta]"]
- Return[$Failed]
- ];
- TMin = Mod[tMin, 2 Pi, tMin];
- TMax = Mod[tMax, 2 Pi, tMin];
- If[TMax == TMin, TMax += 2 Pi];
- mArcTan[vars__] := Mod[ArcTan[vars], 2 Pi, TMin];
- Block[{r,t},
- Fns = TransformedField["Polar" -> "Cartesian", fns, {r, t} -> {x, y}] /. ArcTan -> mArcTan;
- ];
- RMax = rMax;
- StreamPlot[Fns, {x, -RMax, RMax}, {y, -RMax, RMax},
- RegionFunction ->
- Function[{x, y},
- Evaluate[mArcTan[x, y] <= TMax && rMin <= Sqrt[x^2 + y^2] <= rMax]], opts]
- ]
Advertisement
Add Comment
Please, Sign In to add comment