Parametric Trace

Sub[expr_,var_,val_]:=
expr /. var->val;

Sub[expr_,var_,vals_?ListQ]:=
Transpose[Sub[expr,var,#]& /@ vals];

ParametricTrace[{f1_,f2_},{var_,a_,b_},t0_,mode_,plotrange_,places_]:=
Module[{pl,dt,tx,gr,grobjs,t,x,y},

If[a<b,
pl= If[mode===dot || t0>a,First[ParametricPlot[{f1,f2},Evaluate[Switch[mode,dot,{var,a,b},trace,{var,a,t0},segment,{var,t0-0.1,t0+0.1}]],Axes->False,PlotStyle->Blue]],{}];
dt={PointSize[Medium],Style[Point[Sub[{f1,f2},var,t0]],RGBColor[1,.47,0]]};
grobjs = {pl,dt};
{t,x,y} = NumberForm[Chop[N[#,places+2]],{places+2,places},NumberPadding->{" ","0"},ExponentFunction-> (Null&) ]& /@  {t0,Sub[f1,var,t0],Sub[f2,var,t0]};
tx = Text@Row[{Style["t",Italic]," =",t,"  ",Style["x",Italic]," =",x,"  ",Style["y",Italic]," =",y}];

gr=Graphics[grobjs,Axes->True,AspectRatio->Automatic ,AxesOrigin->{Automatic,0}, ImageSize->{400,300},PlotRange->plotrange]
];

Grid[{{tx},{gr}}]
];

ParametricFunctionList = 
{{{2-3t,1-2t},{{-2,2},{-2,2}},{0,1}}->"x = 2 - 3t, y = 1 - 2t",
{{(t^2),t},{{-1,1},{-1,1}},{-1,1}}->"x = (t^2), y = t",
{{(t^3)-2t,(t^2)-t},{{-4,4},{-2,6}},{-2,2}}->"x = (t^3) - 2t, y = \!\(\*SuperscriptBox[\(t\), \(\(2\)\(\\ \)\)]\)- t",
{{((1-(t^2))/(1+(t^2))),((2t)/(1+(t^2)))},{{-1,1},{-1,1}},{-10,10}}->"x = (1 - (t^2))/(1 + (t^2)), y = 2t/(1 + (t^2))",
{{Cos[t],Sin[t]},{{-1,1},{-1,1}},{0,2π}}->"x = cos(t), y = sin(t)",
{{Cos[t],Sin[2t]},{{-1,1},{-1,1}},{0,2π}}->"x = cos(t), y = sin(2t)",
{{Sin[3t],Sin[4t]},{{-1,1},{-1,1}},{0,2π}}->"x = sin(3t), y = sin(4t)",
{{Sin[t+Sin[t]],Cos[t+Cos[t]]},{{-1,1},{-1,1}},{0,2π}}->"x = sin(t + sin(t)), y = cos(t + cos(t))",
{{Cos[t],y=Sin[t+Sin[5t]]},{{-1,1},{-1,1}},{0,2π}}->"x = cos(t), y = sin(t + sin(5t))",
{{(E^(Cos[t])),(E^(Sin[t]))},{{0,3},{0,3}},{0,2π}}->"x = (e^(cos (t))), y = (e^(sin (t)))"
};

Manipulate[If[t0>Last[Last[f]],t0=Last[Last[f]]];
ParametricTrace[First[f],Prepend[Last[f],t],t0,mode,First[Rest[f]],places],
{{f,{{Cos[t],Sin[t]},{{-1,1},{-1,1}},{0,2π}},"equations"},ParametricFunctionList,BaseStyle->{10}},
{mode,{trace,dot,segment}},
{{places,2},Range[2,6],ControlType->PopupMenu,BaseStyle->{9} },
{{t0,0,"t"},First[Last[f]],Last[Last[f]]},
SaveDefinitions->True,AutorunSequencing-> {4}]

CAPTION

Parametric equations such as x = cos(t), y = sin(t) are used to draw curves or represent motion in the plane. As the parameter t changes, the point with coordinates x, y moves.

THIS NOTEBOOK IS THE SOURCE CODE FROM

"Parametric Trace" from the Wolfram Demonstrations Project
 http://demonstrations.wolfram.com/ParametricTrace/

Contributed by: Richard Mercer

A full-function Wolfram Mathematica system (Version 6 or higher) is required to edit this notebook.
GET WOLFRAM MATHEMATICA »

© Wolfram Demonstrations Project & Contributors   |   Terms of Use   |   Make a new version of this Demonstration »