Parametric Circles

by
K. D.  Stroyan
University of Iowa

copyright 1997 by Academic Press, Inc. - All rights reserved.

Special Mathematica Functions used in this NoteBook (proportional arrows)

Off[General::spell];
Off[General::spell1];
Off[ParametricPlot::ppcom]
Needs["Graphics`Colors`"]

SetOptions[Graphics,Axes->False,AxesOrigin->{0,0},AspectRatio->Automatic];
SetOptions[Graphics3D,ViewPoint->{5,2,1},Boxed->False,AspectRatio->Automatic];
SetOptions[ParametricPlot3D,ViewPoint->{5,2,1},AspectRatio->Automatic];
SetOptions[Plot3D,ViewPoint->{5,2,1},AspectRatio->Automatic];
SetOptions[ParametricPlot,AspectRatio->Automatic];
SetOptions[Plot,AspectRatio->Automatic];

colorQ[a_]:=(Head[a]===RGBColor);
grayQ[a_]:=(Head[a]===GrayLevel);
thickQ[a_]:=(Head[a]===Thickness);
absthickQ[a_]:=(Head[a]===AbsoluteThickness);
notruleQ[u_] := !(Head[u]===Rule);
ruleQ[u_] := (Head[u]===Rule);

Norm::usage = "Norm[expr] returns the Euclidean length of the
		vector, 'expr'.";

Norm[a_?VectorQ] := Sqrt[a.a];

Angle[a_?VectorQ,b_?VectorQ] := ArcCos[(a.b)/(Norm[a] Norm[b])]

Proj[a_?VectorQ,b_?VectorQ] := ((a.b)/(b.b))b

tol = .5*10^-6;

OrthUp[a_?VectorQ] :=
	Module[{b,c,d,f},
		d = N[a/Norm[a]];
		If[Chop[d[[3]]^2 - 1,tol] == 0, b={1,0,0} ,
		b = {0,0,1} - d[[3]] d; b = b/Norm[b];];
	Return[b]];
	
OrthSet[a_?VectorQ] :=
	Module[{b,c,d},
		d = N[a/Norm[a]];
		If[Chop[d[[1]],tol]==0,b={1,0,0},
			 If[Chop[d[[2]],tol]==0,b={0,1,0},
			  b={-d[[2]],d[[1]],0}]];
			b=b/Norm[b];c = Cross[d,b];
	Return[{b,c/Norm[c],d}]];

				
Rotate[a_?VectorQ,theta_] :=
	Module[{u,v,r},
		u = OrthSet[a];
		v = Transpose[u];
		r = N[{{Cos[theta],-Sin[theta],0},{Sin[theta],Cos[theta],0},{0,0,1}}];
	Return[v.r.u]];

Vector2D[tail_,tip_,opts___]:=
	Module[{ntail,ntip,sopts,Punit,up,arrow},
	ntail = N[tail];
	ntip = N[tip];
	
	sopts = Join[Select[{opts},colorQ],Select[{opts},
				thickQ],Select[{opts},absthickQ],Select[{opts},grayQ]];

If[Chop[ntail.ntail+ntip.ntip,tol] == 0,
			(*too small to plot or not number*)
			Return[Graphics[Point[{0,0}]]];
	,						
If[Chop[(ntip-ntail).(ntip-ntail),tol] == 0,
		Return[Graphics[{Join[sopts,{Line[{ntail,ntip}]}]}]];
	,
	Punit = (.075 Norm[ntip-ntail]/Norm[ntip-ntail]) (ntip-ntail) ;
	up = 0.15 {-Punit[[2]],Punit[[1]]};
	arrow = Line[{ntail,ntip,ntip-Punit+up,ntip,ntip-Punit-up}];
	]];
Return[Graphics[{Join[{AbsoluteThickness[2]},Join[sopts,{arrow}]]}]];
];

Vector3D[tail_,tip_,opts___]:=
	Module[{ntail,ntip,sopts,Punit,up,u2,u3,u4,rotmat,arrow},
	ntail = N[tail];
	ntip = N[tip];
	
	sopts = Join[Select[{opts},colorQ],Select[{opts},
				thickQ],Select[{opts},absthickQ],Select[{opts},grayQ]];

If[Chop[ntail.ntail+ntip.ntip,tol] == 0,
			(*too small to plot or not number*)
			Return[Graphics3D[Point[{0,0,0}]]];					
	,		
If[Chop[(ntip-ntail).(ntip-ntail),tol] == 0,
		Return[Graphics3D[{Join[sopts,{Line[{ntail,ntip}]}]}]];
	,
	Punit = (ntip-ntail);
	rotmat = Rotate[Punit,N[Pi/2]];
	up = OrthUp[Punit];
	Punit = .075 Punit;
	up = .15 Norm[Punit] up;
	u2 = rotmat.up;
	u3 = rotmat.u2;
	u4 = rotmat.u3;
	arrow = Line[{ntail,ntip,
				ntip - Punit + up,ntip,
				ntip - Punit + u2,ntip,
				ntip - Punit + u3,ntip,
				ntip - Punit + u4}];
	]];
Return[Graphics3D[{Join[{AbsoluteThickness[2]},Join[sopts,{arrow}]]}]];
];

aRCtAN[y_,x_] := Module[{v},
	If[ Chop[N[x],tol] == 0 ,If[ N[y] < 0, v = -N[Pi/2], v = N[Pi/2]],
		v = N[ArcTan[y/x]];
		If[ x < 0 && y < 0, v = N[Pi -  v],v]];
	Return[v]];

Arc2D[X_,Y_,opts___] := Graphics[{opts,
		Disk[{0,0},1,{Min[
							aRCtAN[
						N[X[[2]]],N[X[[1]]]
								]
							,
							aRCtAN[
							N[Y[[2]]],N[Y[[1]]]
								]
						]
						,
					Max[
							aRCtAN[
						N[X[[2]]],N[X[[1]]]
								]
							,
							aRCtAN[
							N[Y[[2]]],N[Y[[1]]]
								]
						]}
				]}
				];
Arc3D[X_,Y_] := 
	Module[{t,U,V},
		U[V_]:= N[(1/Sqrt[V.V]) V];
		Return[Graphics3D[
		Polygon[Append[Table[U[t X + (1-t) Y],{t,0,1,0.1}],{0,0,0}]]
				]
		]
	];

(*Zero Arrow causes trouble. Put in Vector?*)

Vector[tail_,tip_,opts___]:=
	If[Length[N[tail]]==2,Return[Vector2D[tail,tip,opts]],
		Return[Vector3D[tail,tip,opts]]];
		
Arrow[vec_,opts___]:= 
	Module[{a,b},
				If[Length[N[vec]]==2,
				a=ToExpression["Tail"]/.Select[{opts},ruleQ]/.
					{ToExpression["Tail"]->{0,0}};
				Return[Vector2D[a,a+vec,opts]],
				a=ToExpression["Tail"]/.Select[{opts},ruleQ]/.
					{ToExpression["Tail"]->{0,0,0}};
				Return[Vector3D[a,a+vec,opts]]]
				];

Frame2D[delta_] := 
      Graphics[{
            {Green,Line[{{-delta/4,0},{delta,0}}]},
                    Text["x",{1.01 delta,0}],
            {Green,Line[{{0,-delta/4},{0,delta}}]},
                    Text["y",{0, 1.01 delta}]}];

Frame3D[delta_] := 
      Graphics3D[{
            {Green,Line[{{-delta/4,0,0},{delta,0,0}}]},
                    Text["x",{1.01 delta,0,0}],
            {Green,Line[{{0,-delta/4,0},{0,delta,0}}]},
                    Text["y",{0, 1.01 delta,0}],
            {Green,Line[{{0,0,-delta/4},{0,0,delta}}]},
                    Text["z",{0,0,1.01 delta}]}];

View2D[stuff_] := Show[stuff,Frame2D[1]];
View3D[stuff_] := Show[stuff,Frame3D[1]];

Notebook Overview

This NoteBook explores the parametric equation for the circle represented by sine and cosine.  The counterclockwise unit circle centered at the origin is given by the parametric vector:

X[t] = {x[t], y[t]} = {Cos[t], Sin[t]}

References to the Text

This NoteBook goes with Section 16.2 of the text.

Parametric Circles in 2D

The most important parametric equation of all is the unit circle represented by sine and cosine as the parametric vector that follows:

X[t] = {x[t], y[t]} = {Cos[t], Sin[t]}

The parameter in  t  in this representation is the radian measure of the angle or the length measured along the circle starting at  {1,0}.  Let's see the basic graph: (<Enter> the next computation.)

The Unit Circle

Clear[X, x, y, t]; \(x[t_] = Cos[t]; 
y[t_] = Sin[t]; 
\(X[t_] := {x[t], y[t]}; \)\)ParametricPlot[X[t], {t, -π, π}, 
      PlotStyle -> {{Thickness[0.01], Blue}}, 
      AxesLabel -> {"x", "y"}];

The Circle with Motion

The next computation shows a point moving around the circle.

Do[
      arc = ParametricPlot[X[t], {t, 0, s}, 
          PlotRange -> {{-1.1, 1.1}, {-1.1, 1.1}}, 
          PlotStyle -> {{Thickness[0.01], Blue}}, 
          AxesLabel -> {"x", "y"}, 
          DisplayFunction -> Identity]; 
      Show[arc, Arrow[X[s], Red], DisplayFunction -> $DisplayFunction];
        , {s, ((2 π)/20), 2 π, ((2 π)/20)}];

Larger Radii

Larger circles can be obtained by magnifying the vector  X.  Radius  r  is  1  magnified by r:

r X[t] = r*{x[t], y[t]} = {r Cos[t], r Sin[t]}

Let's see some of these:

Clear[X, x, y, t]; \(x[t_] = Cos[t]; 
y[t_] = Sin[t]; 
X[t_] = {x[t], y[t]}; 

    \(ParametricPlot[

      	{X[t], 
		0.5\ X[t], 
		1.5\ X[t], 
		2\ X[t]}, {t, 
        \(-π\), π}, AxesLabel -> {"x", "y"}, 
      PlotStyle -> {Red, DarkGreen, Blue, Orange}]; \)\)

Different Centers

Translated circles can be obtained by adding a constant vector  A = {a,b}  to the vector  X,

X[t] + A = {x[t] + a, y[t] + b} = {Cos[t] + a, Sin[t] + b}

Let's see some of these:

Clear[X, x, y, t]; \(x[t_] = Cos[t]; 
y[t_] = Sin[t]; 
X[t_] = {x[t], y[t]}; 

    \(ParametricPlot[

      	{X[t], 
		X[t] + {0, 1}, 
		X[t] + {0, \(-1\)}, 
		
        X[t] + {1, 0}, 
		X[t] + {1, 1}, 
		X[t] + {1, \(-1\)}, 
		
        X[t] + {\(-1\), 0}, 
		X[t] + {\(-1\), 1}, 
		
        X[t] + {\(-1\), \(-1\)}}, {t, \(-π\), π}, 
      AxesLabel -> {"x", "y"}]; \)\)

Practice Exercises

Copy and modify computations above to plot a circle of radius  2  centered at the point  {-1,3}.

More Exotic Curves: The Cycloid Project

Spiro Graphs or Wheels on Wheels

When wheels roll on wheels you generate curves that look like th drawings from a Spirograph toy.  These are explored in the cycloids project by summing vectors on circles.  Here's a look:

\(Clear[X, A, U, a, b, t, u, v, r, R, s]; 
\(a[t_] = R\ Cos[t]; 

    b[t_] = R\ Sin[t]; 
A[t_] = {a[t], b[t]}; 
u[t_] = r\ Cos[s]; 

    v[t_] = r\ Sin[s]; 
U[t_] = {u[t], v[t]}; 
s = \(\((R + r)\)\ t\)\/r; 

    X[t_] = A[t] + U[t]\)\)R = 5; r = 3; ParametricPlot[X[t], {t, 0, 15 π}, Ticks -> None, 
      AxesLabel -> {"x", "y"}, 
      PlotRange -> {{-10, 10}, {-10, 10}}, 
      PlotStyle -> {Red}];

Exercises

Exercise 16.2.1

Compare parametric plots of the circles

\(Clear\ [X, θ, r, a, b]; 

    X[θ_]\  := \ r {Cos[θ], \ Sin[θ]} + {a, b}; 

    Y[θ_]\  := 
      Expand[\ r \(({Cos[θ], \ \ Sin[θ]} + {a, b})\)]; 

    Print["Stretch and slide"]; 
X[θ]\)Print["Slide and stretch."]Y[θ]

for various values of r, a, b.