MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: ParametricPlot with jumps

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16230] Re: ParametricPlot with jumps
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Fri, 5 Mar 1999 00:40:56 -0500
  • References: <7b89al$4la@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

David Epstein wrote in message <7b89al$4la at smc.vnet.net>...
>I want to do something similar to the following. I have a curve on a
>cylinder. I want to cut the cylinder
>along one of its generators and open it out to a flat strip (the inverse
>process to how cans are made).
>
>If I now use ParametricPlot to see what the curves look like on the flat
>strip, there are jumps where the
>curves cross the generator which has turned into a pair of edges of the
>flat strip. The way
>ParametricPlot treats this situation is to construct an artificial
>interpolation between the two points
>where the curve meets corresponding opposite edges of the strip. What I
>want it to do is not to make
>this interpolation.
>
>One way to achieve this is to solve for when the curve cuts the edge of
>the figure and then do separate plots between each of these intersection
>points. Is this the easiest way, or is there some way of telling
>ParametricPlot not to interpolate over huge distances?
>
>David Epstein
>
>

David,

The following may help

Avoiding Jumps in ParametricPlot

ParametricPlotPlus::usage =
    "ParametricPlotPlus is an extension of ParametricPlot by an extra
option, \
MaxSlope. With MaxSlope->ms (default 5000) the line is broken at segments \
where the absolute slope in either coordinate is greater than ms";


Options[ParametricPlotPlus] =
    Union[Options[ParametricPlot], {MaxSlope -> 5000}];

<< Utilities`FilterOptions`

ParametricPlotPlus[{x_, y_},{t_, r__},(opts___)?OptionQ]:=
Block[
{$DisplayFunction,p,ms,inopts,ppopts,gr,pars,pts,data,splt},
    $DisplayFunction = Identity;
    ms = MaxSlope/.{opts}/.Options[ParametricPlotPlus];
    inopts = Sequence @@ Flatten[{opts}];
    ppopts = FilterOptions[ParametricPlot, inopts];
    p = {};
    gr =
    ParametricPlot[{p={p,t};x,y},{t,r}, Evaluate[ppopts]];
    pars = Drop[Flatten[p],2];
    pts = Cases[gr, Line[l_]:>l,Infinity][[1]];
    data = Transpose[{pts,pars}];
    splt =
    Map[First,
         Split[data,Max[Abs[Divide@@(#1-#2)]]<=ms &],
         {2}
    ];
    gr /. Line[lst_] :> Line /@ splt
]//Show

Examples

ParametricPlotPlus[{x, Tan[x]}, {x, 0, 2Pi}]

ParametricPlotPlus[(1 + Tan[3x]){Cos[x], Sin[x]}, {x, 0, 2Pi},
  PlotRange -> {{-3, 3}, {-3, 3}},
  AspectRatio -> Automatic,
   Frame -> True, Axes -> False]

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565







  • Prev by Date: Annoying problem with >>
  • Next by Date: Fourier transform
  • Previous by thread: Annoying problem with >>
  • Next by thread: Re: ParametricPlot with jumps