Re: MaxBend in ParametricPlot?

*To*: mathgroup at smc.vnet.net*Subject*: [mg13042] Re: MaxBend in ParametricPlot?*From*: weber at math.uni-bonn.de (Matthias Weber)*Date*: Sat, 4 Jul 1998 16:44:47 -0400*Organization*: RHRZ - University of Bonn (Germany)*References*: <6n9qfj$a7h@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

In article <6n9qfj$a7h at smc.vnet.net>, "Jrgen Tischer" <jtischer at col2.telecom.com.co> wrote: > Ted, you are very kind. Indeed, thanks to Ted I now understand the behaviour of the adaption process behind Plot and ParametricPlot near horizontal/vertical parts of the plot better. > I think it's a deep misunderstanding on behalf of Matthias to expect a > carefully adapted algorithm for rendering on an anisotropic device to > give > isotropic results. Certainly. I don't think it is the task of ParametricPlot to generate device specific graphics instructions. If the approximation of a curve by a polygon is not smooth enough, one should approximate it by (say) Bezier splines (which are available in postscript, though not in Mathematica's current driver as far as I know), and not try to solve the smoothness problem within the part of the algorithm which should supply the user with a reusable object. > I confess I was too lazy to write the function to > solve > Matthias' problem. You are forgiven here. Below a simple uniform adaptive solution, which fulfills at least my needs. I haven't benchmarked it, but if one puts MaxBend->5, I get usually less points than ParametricPlot and it scales pretty well too. And I can use the resulting object for transformations like rotations or to compose 3D objects from it. There is no help button available for this function, but if you ask, Jürgen will certainly supply one. Matthias Options[AdaptivePlot]={PlotPoints->25, MaxBend->10}; angle[p_,q_]:=Abs[Arg[(q[[1]]+I q[[2]])/(p[[1]]+I p[[2]])]]; surround[expr_, elem_]:=Prepend[Append[expr,elem],elem]; AdaptivePlot[f_,range_,opts___]:=Module[{h,xini,zini,l,pp,mb,x2,z2,kink}, pp=PlotPoints/.{opts}/.Options[AdaptivePlot]; mb=MaxBend /.{opts}/.Options[AdaptivePlot]; h=N[(range[[3]]-range[[2]])/pp]; xini=N[Range[range[[2]],range[[3]],h]]; l=Length[xini]; zini=Map[N[f/.range[[1]]->#]&, xini]; kink=surround[ Table[180/Pi *angle[zini[[i+1]]-zini[[i]],zini[[i]]-zini[[i-1]]]>mb,{ i,2,l-1}],False]; While[Or@@kink, x2=Append[ Table[If[kink[[i]]||kink[[i+1]],(xini[[i]]+xini[[i+1]])/2,{}],{i,1, l-1}],Null]; z2=Map[If[NumberQ[#], N[f/.range[[1]]->#],Null]&,x2]; xini=Select[Flatten[Transpose[{xini,x2}]],NumberQ]; l=Length[xini]; zini=Select[Flatten[Transpose[{zini,z2}],1],ListQ]; kink=surround[ Table[180/Pi *angle[zini[[i+1]]-zini[[i]],zini[[i]]-zini[[i-1]]]> mb,{i,2,l-1}],False]; ]; Show[Graphics[Line[zini]]] ];