Parametric Lines

by
K. D.  Stroyan
University of Iowa

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

Special Mathematica Functions used in this NoteBook

This horrible stuff sets various defaults and defines some functions needed to draw the geometric side of the lexicon.  Ignore the details here and go on to the lesson.

Off[General::spell];
Off[General::spell1];
Off[ParametricPlot3D::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 shows you the parametric equations of a line in 2-D or 3-D.

References to the Text

The parametric line is the most basic curve in Chapter 16.  This NoteBook follows Section 16.1.

Step-by-step Parametric Lines

The parametric equations for a line can be derived from the interpretation of vector sum and scalar multiplication.  We want to draw a line through the tip of a vector  P  in the direction of a vector  V.

P = {2, 3, 1}; V = {-3, -2, 1}; View3D[{Arrow[P, Orange], Arrow[V, Red]}];

It would be better to draw  V  with its tail at the tip of  P:

View3D[{Arrow[P, Orange], Arrow[V, Tail -> P, Red]}];

The position vector that points from the origin to the tip of  V  when it is drawn with its tail at the tip of  P  is the vector  X = P + V shown in the next computation.  This is the geometric interpretation of vector sum.

X = P + VView3D[{Arrow[P, Orange], Arrow[V, Tail -> P, Red], 
        Arrow[X, Blue]}];

The parametric equations for the line through  P  in the direction of  V  describe the set of all the position vectors that can be obtained by placing a stretch of  V  with its tail at the tip of  P  and connecting to the origin. The algebraic form of a stretch of a vecotr  V  is the scalar multiple  t V.  Hence, placing a stretch of  V  with its tail at the tip of  P  locates the point  X = P + t V.  For example, here is  X = P + (1/2) V:

X = P + 0.5 VW = 0.5 V; View3D[{Arrow[P, Orange], Arrow[V, Tail -> P, Red], 
        Arrow[X, Blue], Arrow[W, Tail -> P, Brown]}];

Here is  X = P + (1/3) V:

X = P + (1/3.)  V\(W = \(1\/3. \) V; 

    View3D[{Arrow[P, Orange], Arrow[V, Tail -> P, Red], Arrow[X, Blue], 
        Arrow[W, Tail -> P, Brown]}]; \)

Here is  X = P + (-2/3) V:

X = P - ((2 V)/3.) W = -((2 V)/3.) ; View3D[{Arrow[P, Orange], Arrow[V, Tail -> P, Red], 
        Arrow[X, Blue], Arrow[W, Tail -> P, Brown]}];

Practice Exercise

Draw the vectors  P (in Brown) and  X = P + t V (in Blue)  for  P = {2,3,1}, V = {-3,-2,1}.  Also draw the arrows parallel to  V and  W = t V, but with their tails at the tip of  P, for  t = 3/2, 2, 3, -1, -3/2, -2.

Animated Parametric Lines

Given two vectors  P  and  V, the collection of all vectors  X  of the form  X = P + t V, for scalar multiples  t, forms the line through the tip of  P  in the direction parallel to the velocity vector  V.  This fact is animated in 2-D and 3-D below.

2-D

Clear[X, P, V, t]; P = {1, 2}; V = {3, -2}; V = (V/Norm)[V]; SetOptions[Graphics, 
      PlotRange -> {{-1, 4}, {-0.5, 4.5}}]; Do[
      View2D[{Graphics[{DarkGreen, Line[{P - 2 V, P + 2 V}]}], 
          Arrow[P, Purple], Graphics[Text["P",  .6 P]], 
          Arrow[V, Tail -> P, Red], Arrow[P + t V, Blue], 
          Graphics[Text["P + t V",  .6 (P + t V)]], 
          Arrow[t V, Tail -> P, Brown], 
          Graphics[Text["t V", 1.1 (P + ((t V)/2))]]}]; 
      , {t, -2, 2, 0.25}]; SetOptions[Graphics, PlotRange -> Automatic];

Practice Exercise

Sketch the line given parametrically by hand as follows.

1)  Write the equations in vector form  X = P + t V.
	2)  Sketch  P and put a dot at its tip.
	3)  Sketch  V  with its tail at the tip of  P.
	4)  Fill in the line through the shaft of V.

Verify your sketch by modifying the animation above to draw the moving blue point.

x = 3 - 2 t
	y = 2 + t

3-D

Clear[X, P, V, t]; P = {1, 1, 3}; V = {-2, 4, -1}; V = (V/Norm)[V]; SetOptions[Graphics3D, 
      PlotRange -> {{0, 4}, {- .7, 3.3}, {0, 4}}]; Do[
      View3D[{Graphics3D[{DarkGreen, Line[{P - 2 V, P + 2 V}]}], 
          Arrow[P, Purple], Graphics3D[Text["P",  .6 P]], 
          Arrow[V, Tail -> P, Red], Arrow[P + t V, Blue], 
          Graphics3D[Text["P + t V",  .6 (P + t V)]], 
          Arrow[t V, Tail -> P, Brown], 
          Graphics3D[Text["t V", 1.1 (P + ((t V)/2))]]}]; 
      , {t, -2, 2, 0.25}]; SetOptions[Graphics3D, PlotRange -> Automatic];

Practice Exercise

Modify the program above to animate motion along the line through the tip of  P = {2,3,1}  in the direction of velocity  V = {-3,-2,1}.  Write the equations  X = P + t V in classical form

YOUR ANSWER:
		x = ? + ? t
		y = ? + ? t
		z = ? + ? t

Clear[X, x, y, z, P, V, t]; P = {2, 3, 1}; V = {-3, -2, 1}; X = {x, y, z}; Print[TableForm[X], "=", TableForm[P + t V]];

ParametricPlot

Mathematica has commands to plot parametric equations as follows:

2-D

Clear[X, P, V, t]; P = {1, 2}; V = {3, -2}; X[t_] := P + t VX[t]ParametricPlot[Evaluate[X[t]], {t, -1, 3}, 
      PlotStyle -> {Thickness[0.01], Red}];

3-D

Clear[X, P, V, t]; P = {1, 1, 3}; V = {-2, 4, -1}; X[t_] := P + t VX[t]ParametricPlot3D[Evaluate[X[t]], {t, -1, 3}];

Practice Exercise

1)  Use ParametricPlot[.] to graph

x = 2 - t
	y = -1 + 3 t

1)  Use ParametricPlot3D[.] to graph

x = 2 - t
	y = -1 + 3 t
	z = 3 - 2 t

Two Points Determine a Line

Two points determine a line, so given two vectors, we should be able to find the parametric equations describing that line.  This is easily obtained from the geometric interpretation of vecotr difference:

A = {4, 5, 2}; B = {1, -2, 3}; AB = B - AvectorPlot = 
      View3D[{Arrow[A, Blue], Arrow[B, Orange], 
          Arrow[AB, Tail -> A, Red]}];

Clear[X]; X[t_] := A + t (B - A); linePlot = ParametricPlot3D[X[t], {t, -1.1, 1.1}];

Show[linePlot, vectorPlot];

Text Example 16.3: Non-uniqueness

Show that both of the following parametric lines go through both of the points

R = {2,3,4}  and  Q = {1,-2,3}:

LINE1:
	x = 1 +  t
	y =-2 + 5t
	z = 3 + t

LINE2:	
	x = 2 - 2s
	y =3 - 10s
	z = 4 - 2s

In other words find values  t1  and  t2  so the first equations hit,  {x,y,z} =  Q1  and  {x,y,z} = Q2, then find  s1  and  s2  so the second equations hit {x,y,z} = Q1  and {x,y,z} = Q2.

\(Clear[Q, R, P1, P2, V1, V2, X1, X2]; 
R = \ {2, 3, 4}; 

    Q\  = \ \ {1, \(-2\), 3}; 
P1\  = \ {1, \(-2\), 3}; 

    V1\  = \ {1, 5, 1}; 
P2\  = \ {2, 3, 4}; 

    V2\  = \ {\(-2\), \(-10\), \(-2\)}; 
X1[t1_]\  := \ P1\  + \ t1\ V1; 

    X2[t2_]\  := \ P2\  + \ t2\ V2; 
Solve[R\  == \ X1[t1]]\)Solve[R  ==  X2[t2]]Solve[Q ==  X1[t1]]Solve[Q ==  X2[t2]]

Plug in and check:

RX1[1]X2[0]

QX1[0]X2[1/2]

Plot both sets of equations and observe that they are the same line containing Q and R:

\(curve1\  = \ ParametricPlot3D[X1[t1], {t1, \(-1\)/2, 3/2}]; 

    Show[curve1, Frame3D[2], Arrow[R, Red], Arrow[Q, Blue]]; \)

\(curve2\  = \ ParametricPlot3D[X2[t2], {t2, \(-1\)/2, 3/2}]; 

    Show[curve2, Frame3D[2], Arrow[R, Red], Arrow[Q, Blue]]; \)

Show[curve1, curve2];

Example 16.4: Distance from  0  to the Line  X = P + t V,
		 | P - (P . (V/V) . V) V |

This example shows you how to use the geometric-algebraic lexicon to find the distance from the origin to the line  X = P + t V.

1)  Let  P = {1,3,1}  and  V = {-2,-3,1}.  Draw the line through the tip of  P  in a direction parallel to  V.  (This uses the lexicon entry for vector sum.)

\(P = {1, 3, 1}; 
\(V = {\(-2\), \(-3\), 1}; \)\)\(\(View3D[{Graphics3D[{Green, Line[{P - 2\ V, P + 2\ V}]}], 
		
        Arrow[P, Orange], Graphics3D[Text["P",  .6\ P]], 
		
        Arrow[V, Tail -> P, Red], 
        Graphics3D[Text["V",  .6\ V + 1.1\ P]]}]; \)\)

2)  Compute a vector  R = the projection of  P  in the direction of  V  and add it to our figure.  (This uses the lexicon entry for perpendiculer projection.)

R = ((V . P )/V) . V VView3D[{Graphics3D[{Green, Line[{P - 2 V, P + 2 V}]}], 
        Arrow[P, Orange], Arrow[V, Tail -> P, Red], Arrow[R, Brown], 
        Graphics3D[Text["R", 1.1 R]]}];

3)  Compute the vector Q that points from the tip of  R to the tip of  P.  Sketch Q it with its tail at the tip of R.  (This uses the lexicon entry for displacement vectors  by vector difference.)

Q  =  P - R\(\(View3D[{Graphics3D[{Green, Line[{P - 2\ V, P + 2\ V}]}], 
		
        Arrow[P, Orange], Graphics3D[Text["P", 1.1  P]], 
		
        Arrow[V, Tail -> P, Red], Arrow[R, Brown], 
        Graphics3D[Text["R", 1.1  R]], 
		Arrow[Q, Tail -> R], 
        Arrow[Q, DarkGreen], Graphics3D[Text["Q", 1.2  Q]]}]; \)\)

4)  The tip of the position vector  Q is a point on the line because it satisfies the equation X = P + t V

Here's Proof that Q lies on the line:
WANT: t  so  Q = P + t V
KNOW: Q = P - R = P - ((V . P )/V) . V V
TAKE:  t = -((V . P )/V) . V, then  Q = P + t V  and  Q  lies on the line.

5)  Prove that  Q  is perpendicular to the line:  It suffices to prove that Q is perpendicular to the direction vector V.  This happens if  Q.V = 0, so we compute:

Q.V = (P-R).V = P.V - R.V

Now use the formula for R = ((V . P )/V) . V V

Q.V= P.V - R.V = P.V - (((V . P )/V) . V V) . V = P.V - V . (P/V) . V V . V = 0

6)  The distance from the origin to the line is the length of Q, so:
Distance from  0 to the line  X = P + t V:

| Q | =  | P - (P . (V/V) . V) V |

Norm[Q]Norm[P  -  (P . (V/V) . V) V]

Exercises

Problem 16.1

Let  P = {1,3,1}  and  V = {-2,-3,1}.  We will build up many points  X  on the line through the tip of  P  in a direction parallel to  V.

a)  Let  t = 1.

a.1)  Draw the position vector  P  in Blue.

a.2)  Draw the vector  t V  as a position vector in Red and as a displacement vector with its tail at the tip of  P  in Brown.

a.3)  Compute  X = P  + t V  and plot it as a position vector in Blue.

P = {1,3,1};
V = {-2,-3,1};
t = 1;
???

b)  Let  t = 1/2.

b.1)  Draw the position vector  P  in Blue.

b.2)  Draw the vector  t V  as a position vector in Red and as a displacement vector with its tail at the tip of  P  in Brown.

b.3)  Compute  X = P  + t V  and plot it as a position vector in Blue.

c)  Let  t = 3.

c.1)  Draw the position vector  P  in Blue.

c.2)  Draw the vector  t V  as a position vector in Red and as a displacement vector with its tail at the tip of  P  in Brown.

c.3)  Compute  X = P  + t V  and plot it as a position vector in Blue.

d)  Let  t = 3.

d.1)  Draw the position vector  P  in Blue.

d.2)  Draw the vector  t V  as a position vector in Red and as a displacement vector with its tail at the tip of  P  in Brown.

d.3)  Compute  X = P  + t V  and plot it as a position vector in Blue.

e)  What is the set of tips of position vectors  X  of the form  X = P + t V, as  t  runs through all real numbers?

f)  Explain why the coordinate equations  {x,y,z} = {1,3,1} + t {-2,-3,1} or

x = 1 - 2 t
	y = 3 - 3 t
	z = 1 + t

describe a parametric line that goes through the point at the tip of  P  and points in a direction parallel to the vector  V = {-2,-3,1}.

g)  Sketch this line by hand and with Mathematica.

Exercise 16.1.2

The classical parametric equations

x = 3 - 4 t
	y = 1 +  t
	z = 2

describe a line.

1)  Write the equations in vector form  X = P + t V.  What are the vectors  P  and  V?

2)  Sketch the line by hand and draw it with Mathematica.

3)  Find two non-parallel vectors  M and  N  both perpendicular to the direction of this line.

Exercise 16.1.3: Vector Equations

Find parametric equations of the line through the points and sketch using Mathematica.

R = {1,2,3}  and  Q = {-1,3,2}:

Sketch the displacement vector from Q to R.

Give the vector equations  X = P + t V

Exercise 16.1.4: Non-uniqueness

Show that both lines:

x = 1 + 2t		x = 3 - s
y = 2 - 4 t		y = -2+2 s
z = 3 - 2 t		z = 1 + s

contain the points

R = {1,2,3}  and  Q = {-1,3,2}

Sketch  Q, R and the line.

\(t\  = \ 1; 
s\  = \ 0; 
{1\  + \ 2  t, 2 - 4  t, 3 - 2  t}\){3 - s, -2 + 2  s, 1 + s}

Problem 16.2: Distance from a point Y to a line  X = P + t V

Use the ideas of the Example 16.4 to compute the distance from an arbitrary point  Y  to the line  X = P + t V.  We want a vector perpendicular to the line that points from  Y  to a point on the line.

P = {1, 3, 1}; V = {-2, -3, 1}; Y = {4, -2, 1}; View3D[{Graphics3D[{Green, Line[{P - 2 V, P + 2 V}]}], 
        Arrow[P, Orange], Graphics3D[Text["P",  .6 P]], 
        Arrow[V, Tail -> P, Red], Arrow[Y, Brown], 
        Graphics3D[Text["Y", 1.1 Y]]}];

In the previous exercise, we learned we can subtract the projection of  P  in the direction of  V  to find a vector  Q  that points from the origin to the line and is perpendicular to the line.  One approach is to "move the origin" so this problem is reduced to that one.  Suppose we consider the line  Z = (P-Y) + t V.  How does this look in relation to  X = P + t V and the point  Y?

P = {1, 3, 1}; V = {-2, -3, 1}; Y = {4, -2, 1}; View3D[{Graphics3D[{Green, Line[{P - 2 V, P + 2 V}]}], 
        Arrow[P, Orange], Graphics3D[Text["P",  .6 P]], 
        Arrow[V, Tail -> P, Red], Arrow[Y, Brown], 
        Graphics3D[Text["Y", 1.1 Y]]}];

View3D[{Graphics3D[{Green, Line[{P - Y - 2 V, P - Y + 2 V}]}], 
        Arrow[P, Tail -> -Y, Orange], 
        Arrow[V, Tail -> P - Y, Red], 
        Arrow[Y, Tail -> -Y, Brown]}];

The vector from the new origin to the line is  P - Y:

\(\(View3D[{Graphics3D[{Green, Line[{P - Y - 2\ V, P - Y + 2\ V}]}], 
        Arrow[P, Tail -> \(-Y\), Orange], 
        Arrow[V, Tail -> P - Y, Red], 
        Arrow[Y, Tail -> \(-Y\), Brown], Arrow[P - Y, Blue]
		, 
        Graphics3D[Text["P-Y", 1.1 \((\ P - Y)\)]]}]; \)\)

So we can apply the distance formula of Example 16.4 (see above or in the text) to the Blue vector: distance = ???