Moving in Three Dimensions

Introduction

OBJECTIVE: Learn to use Mathematica to perform calculations to analyze motion in the equations that are given parametrically.

Moving in three dimensions is something with which we are familiar, but visualization of equations of motion and computations involved in analyzing that motion can be cumbersome. This module gives a broad overview on the analysis of motion where the equations are given parametrically.

Technology Guidelines

NOTE:  If you have just finished a module, restart Mathematica or Quit Kernel under the Evaluation pull-down menu before executing a new module.
TO OPEN CELLS, click on the arrow to the left of the cell or put your cursor on the right cell bracket and double click. To open all cells, highlight the bracket on the far right and select Grouping under the Cell pull-down menu and select Open All Subgroups.
TO STOP AN EXECUTION
Select the Evaluation pull-down menu and click on Abort Evaluation.
ORDER OF EXECUTION
Execute cells in the order given. Do not skip any Input cells within a given notebook.
SAVING NOTEBOOKS
You can save anytime to any directory you choose, and it is wise to save often. However, before you do your final save to reduce the size of your file, it is a good idea to delete all your output by selecting the Delete All Output selection under the Cell pull-down menu.
EXPERIENCING MAJOR PROBLEMS
Save if appropriate, then shut down Mathematica and start it up again.

Part I: Parametric Equations of a Curve in 3-Space

First, we define the x, y, and z coordinates for motion parametrically.

Clear[x,y,z,t]
x[t_]:=Cos[t]
y[t_]:=Sin[t]
z[t_]:=4-(t^2)/25

Next, we plot the resulting curve in blue. Can you tell in which direction you are moving on the curve as t increases?

pf=ParametricPlot3D[{x[t],y[t],z[t]},{t,0,10},ColorFunction->Function[{x,y,z},RGBColor[0,0,1]],AxesLabel->{"x","y","z"}]

If you consider the parametric equation as a vector equation for the motion of a particle, the derivative of that vector is the velocity vector that we form by differentiating each component. The commands below plot both the first and second derivative of the vector position function.

\[MathematicaIcon] About Mathematica

Print["The velocity vector is ",{x'[t],y'[t],z'[t]}] 
pv=ParametricPlot3D[{x'[t],y'[t],z'[t]},{t,0,10},ColorFunction->Function[{x,y,z},RGBColor[1,0,0]],AxesLabel->{x,y,z}]
Print["The acceleration vector is ",{((x'))'[t],((y'))'[t],((z'))'[t]}] 
pa=ParametricPlot3D[{((x'))'[t],((y'))'[t],((z'))'[t]},{t,0,10},ColorFunction->Function[{x,y,z},RGBColor[0,1,0]],AxesLabel->{x,y,z}]

The following command plots all three functions together, with the position in blue, the velocity in red, and the acceleration in green. You can see that the acceleration in the vertical direction is a negative constant, so the velocity in that direction is decreasing at a linear rate, causing the motion to spiral down at a rate proportion to (t^2). The motion, velocity, and acceleration in the x and y directions are circular.

Show[pf,pv,pa,PlotRange->All]

You Try It: Part I

Define your own x, y, and z coordinates for motion by changing the entries in red. You may or may not want to change the time interval (in red) over which you plot your functions.

Clear[x,y,z,t]
x[t_]:=10 Exp[Cos[t]]
y[t_]:=10 Sin[((t^2)/15)]
z[t_]:=((t^2)/2)
timeinterval=5;pf2=ParametricPlot3D[{x[t],y[t],z[t]},{t,0,timeinterval},ColorFunction->Function[{x,y,z},RGBColor[0,0,1]],AxesLabel->{"x","y","z"}]

Now check out the velocity and acceleration.

Print["The velocity vector is ",{x'[t],y'[t],z'[t]}] 
pv2=ParametricPlot3D[{x'[t],y'[t],z'[t]},{t,0,timeinterval},ColorFunction->Function[{x,y,z},RGBColor[1,0,0]],AxesLabel->{x,y,z}]
Print["The acceleration vector is ",{((x'))'[t],((y'))'[t],((z'))'[t]}] 
pa2=ParametricPlot3D[{((x'))'[t],((y'))'[t],((z'))'[t]},{t,0,timeinterval},ColorFunction->Function[{x,y,z},RGBColor[0,1,0]],AxesLabel->{x,y,z}]
Show[pf2,pv2,pa2,PlotRange->All]

The plot of all three together may or may not be instructive.

Compare your results to those of your classmates.

Part II: Equations of Motion
Velocity -> Position  
Velocity -> Acceleration

If you are given the velocity, you can differentiate to find the acceleration and integrate to find the displacement. Since we do three integrations, we need three arbitrary constants to get the general solution.

Clear[position, velocity, acceleration,t,a,b,c]
Print["The velocity vector is defined to be ",velocity={3/2(((t+1))^(1/2)),(E^(-t)),1/(t+1)}]
Print["The acceleration vector is ",acceleration=D[velocity,t]]
Print["The position vector is ",rgeneral=Integrate[velocity,t]+{a,b,c}]

To evaluate the constants of integration in the formula for displacement (rgeneral), we need to apply the initial conditions. The following command computes those constants for an initial position of  (1,1,0).

initial={1,1,0};
constants=Solve[(rgeneral/.t->0)==initial,{a,b,c}]

We evaluate our position vector with the constants replaced by the values just determined.

r=rgeneral/.constants

You Try It: Part II

Change the entries in your velocity vector and your initial position (items in red), and re-execute the cell.

Clear[a,b,c,t]
velocity={3/2(((t+1))^(1/2)),(E^(-t)),1/(t+1)}
acceleration=D[velocity,t]
rgeneral=Integrate[velocity,t]+{a,b,c}
initial={1,1,0};
constants=Solve[(rgeneral/.t->0)==initial,{a,b,c}]
r=rgeneral/.constants

Part III: Computing the Distance Traveled on a Curved Path

Suppose that you are walking up a mountain along the path given below. You can use the following code to compute the distance traveled in the first ten minutes, where t stands for time in minutes and distance is measured in feet.

Clear[r,t,v]
Print["The postion given in feet is ",r[t_]={3 Cos[2 t],((t^(10/3))/50),t}];
ParametricPlot3D[Evaluate[r[t]],{t,0,10}]
Print["The velocity vector given in feet per minute is ",v[t_]=r'[t]]
Simplify[Print["The speed (ds/dt) in feet per minute is ",speed=(Sqrt[v[t].v[t]])]]
Print["The distance traveled in feet in 10 minutes is ",distance=NIntegrate[speed,{t,0,10}]]

In the above example, if you had tried to integrate symbolically, instead of numerically, what would have happened? (The N in front of the Integrate signifies numerical integration.) Many integrals arising in the computation of arc length are too complicated to evaluate symbolically.

Integrate[speed,{t,0,10}]

Check your speed after five minutes and plot your speed during the first ten minutes.

Print["speed at 5 minutes is ",speed/.t->5.`," feet per minute"]
Plot[speed,{t,0,10},AxesLabel->{t,"speed"}]

If t represents time in minutes, what does this say about the speed of the hiker? Is it possible?

You Try It: Part III

Choose your own position function and the interval over which you wish to integrate (terms in red).

Clear[r,t,v]
Print["The postion vector given in feet is ",r[t_]={2 (t^(0.3`)),Cos[t-1],Exp[-(t^2)]}];ParametricPlot3D[Evaluate[r[t]],{t,0,10}]
Print["The velocity given in feet per minute is ",v[t_]=r'[t]]
Simplify[Print["The speed (ds/dt) in feet per minute is ",speed=(Sqrt[v[t].v[t]])]]
Print["The distance traveled in feet in the first 10 minutes is ",distance=NIntegrate[speed,{t,0,10}]]

Part IV: Computing Curvature and Torsion for a Space Curve

Mathematica simplifies the process of finding curvature and torsion. The computations below use formulas directly from your text, and we graphically explore the interpretations of the curvature and torsion functions.

Clear[r,v,t,speed]
mag[vector_]:=(Sqrt[vector.vector])
Print["The position vector is ",r[t_]={10Sin[t],10Exp[-t],((t^(10/3))/100)}]
Print["The velocity vector is ",v[t_]=r'[t]]
Print["The acceleration vector is ",a[t_]=v'[t]]
Print["The speed is ",speed[t_]=mag[v[t]]]
Print["The unit tangent vector is ",utan[t_]=v[t]/speed[t]//Simplify]
Print["The curvature is ",curvature[t_]=mag[Cross[v[t],a[t]]]/((speed[t])^3)//Simplify]
Print["The torsion is ",torsion[t_]=Det[{v[t],a[t],a'[t]}]/(Cross[v[t],a[t]].Cross[v[t],a[t]])//Simplify]

Let's visualize some of these quantities. We will begin by drawing the path of motion.

ParametricPlot3D[Evaluate[r[t]],{t,0,10},AxesLabel->{x,y,z}]

Print["The speed is ",speed[t]]
ps=Plot[Evaluate[speed[t]],{t,0,10},AxesLabel->{t,speed},PlotStyle->RGBColor[1,0,0],AxesOrigin->{0,0}]

Print["The curvature is ",curvature[t]]
pc=Plot[Evaluate[curvature[t]],{t,0,10},AxesLabel->{t,curvature},PlotRange->All,PlotStyle->RGBColor[0,1,0]]

Print["The torsion is ",torsion[t]]
pt=Plot[Evaluate[torsion[t]],{t,0,10},AxesLabel->{t,torsion},PlotStyle->RGBColor[0,0,1],PlotRange->All]

Show[ps,pc,pt,PlotRange->{-5,15}]
Print["speed in red, curvature in green, torsion in blue"]

Look at your space curve, and see if you can identify the points on your space curve at which the curvature or torsion spike. What has caused these events? Are they related at all to the speed?

From the definition of curvature that relates it to the cross product of the velocity and acceleration, recall that the curvature is smallest when the velocity and acceleration are in the same direction. The curvature is largest when the velocity and acceleration are perpendicular to one another.

Consider torsion as the dot product of the derivative of the unit binormal and the normal vectors. Torsion will peak when those two vectors are in the same direction and will be close to 0 when those two vectors are perpendicular.

ParametricPlot3D[Evaluate[r[t]],{t,0,10},AxesLabel->{x,y,z}]

See the TNB frame for a curve in action in Part VI of this module.

You Try It: Part IV

Redefine your position function (in red) and compute it. Note that the computations here are not trivial, so complicated functions may take some time to compute.

Clear[r,v,t,speed]
mag[vector_]:=(Sqrt[vector.vector])
Print["position vector is ",r[t_]={2 (t^(0.3`)),Cos[t-1],Exp[-(t^2)]}]
Print["velocity vector is ",v[t_]=r'[t]]
Print["acceleration vector is ",a[t_]=v'[t]]
Print["speed is ",speed[t_]=mag[v[t]]]
Print["unit tangent vector is ",unittangent[t_]=Simplify[((v[t])/(speed[t]))]]
Print["curvature is ",curvature[t_]=Simplify[((mag[v[t]\[Cross]a[t]])/(Abs[((speed[t])^3)]))]]
Print["torsion is ",torsion[t_]=Simplify[Det[{v[t],a[t],a'[t]}]/((mag[v[t]\[Cross]a[t]])^2)]]
ParametricPlot3D[Evaluate[r[t]],{t,0,5},AxesLabel->{x,y,z}]

Print["speed = ",speed[t]]
ps=Plot[Evaluate[speed[t]],{t,0,10},AxesLabel->{t,speed},PlotStyle->RGBColor[1,0,0],AxesOrigin->{0,0}]
Print["curvature = ",curvature[t]]
pc=Plot[Evaluate[curvature[t]],{t,0,10},AxesLabel->{t,curvature},PlotRange->All,PlotStyle->RGBColor[0,1,0],AxesOrigin->{0,0}]
Print["torsion = ",torsion[t]]
pt=Plot[Evaluate[torsion[t]],{t,0,10},AxesLabel->{t,torsion},PlotStyle->RGBColor[0,0,1],AxesOrigin->{0,0},PlotRange->All]
Show[ps,pc,pt,PlotRange->{-5,15}]
Print["speed in red, curvature in green, torsion in blue"]

Part V: TNB Frame-Computation and Visualization

The steps here resemble the ones above, except that we choose a simpler function and extend the formulas to the unit normal and binormal vectors.

Clear[r,v,a,t,speed,curvature,torsion]
mag[vector_]:=(Sqrt[vector.vector])
Print["The position vector is ",r[t_]={Sin[2t],Cos[2t],((t^2)/10)}]
Print["The velocity vector is ",v[t_]=r'[t]]
Print["The acceleration vector is ",a[t_]=v'[t]]
Print["The speed is ",speed[t_]=mag[v[t]]//Simplify]
Print["The unit tangent vector is ",utan[t_]=v[t]/speed[t]//Simplify]
Print["The curvature is ",curvature[t_]=mag[Cross[v[t],a[t]]]/((speed[t])^3)//Simplify]
Print["The torsion is ",torsion[t_]=Det[{v[t],a[t],a'[t]}]/((mag[Cross[v[t],a[t]]])^2)//Simplify]
top=utan'[t]//Simplify;
bottom=mag[top]//Simplify;
Print["The unit normal is ",un[t_]=top/bottom//Simplify]
Print["The unit binormal is ",ubn[t_]=Cross[utan[t],un[t]]//Simplify]

Let's find the tangential and normal components of the accelerations.

Print["The tangential component of acceleration is ",at[t_]=a[t].utan[t]//Simplify]
Print["The normal component of acceleration is ",an[t_]=a[t].un[t]//Simplify]

You can get a visual perspective of the tangential and normal components of the acceleration in two dimensions by exploring the Java applet, "Tangent and Normal Vectors."

If you compare these components found by the dot products to the formulas given in your book, you will see that they agree, once the absolute value sign is removed from the curvature formula.

at[t]==speed'[t]//Simplify
an[t]==curvature[t] ((speed[t])^2)//Simplify

The equality of the tangential components is verified. Although Mathematica cannot completely simplify the results, you can see that the normal components are equal also.

The following set of commands will plot the unit tangent, unit normal, and unit binormal vectors as you move along the curve.

After the plot is generated, you can move the slider at the top to  animate the TNB vectors as they move along the curve. You can also change your view of the curve with your cursor.

Off[ParametricPlot3D::"ppcom"];
r[t_]={Sin[2t],Cos[2t],((t^2)/10)};
Manipulate[
p1=ParametricPlot3D[r[t],{t,0,2.π},PlotRange->{{-1.5,1.5},{-1.5,1.5},{0,4}}];
p2=Graphics3D[{Thickness[0.02],RGBColor[1,0,0],Line[{r[t],r[t]+utan[t]}/.t->ta]}];
p3=Graphics3D[{Thickness[0.02],RGBColor[0,1,0],Line[{r[t],r[t]+un[t]}/.t->ta]}];
p4=Graphics3D[{Thickness[0.02],RGBColor[0,0,1],Line[{r[t],r[t]+ubn[t]}/.t->ta]}];
p5=Graphics3D[{Dashing[0.01],Line[{r[t]+0.20*utan[t],r[t]+0.20*utan[t]+0.20*ubn[t]}/.t->ta],Line[{r[t]+0.20*ubn[t],r[t]+0.20*ubn[t]+0.20*utan[t]}/.t->ta],Line[{r[t]+0.20*utan[t],r[t]+0.20*utan[t]+0.20*un[t]}/.t->ta],Line[{r[t]+0.20*un[t],r[t]+0.20*un[t]+0.20*utan[t]}/.t->ta],Line[{r[t]+0.20*un[t],r[t]+0.20*un[t]+0.20*ubn[t]}/.t->ta],Line[{r[t]+0.20*ubn[t],r[t]+0.20*ubn[t]+0.20*un[t]}/.t->ta],Line[{r[t]+0.20*utan[t]+0.20*ubn[t],r[t]+0.20*utan[t]+0.20*ubn[t]+0.2*un[t]}/.t->ta],Line[{r[t]+0.20*utan[t]+0.20*un[t],r[t]+0.20*utan[t]+0.20*ubn[t]+0.20*un[t]}/.t->ta],Line[{r[t]+0.20*un[t]+0.20*ubn[t],r[t]+0.20*utan[t]+0.20*ubn[t]+0.20*un[t]}/.t->ta]}];
Show[p1,p2,p3,p4,p5],{ta,0,2π,Appearance->"Labeled"},TrackedSymbols:>{ta}]

Move the slider at the top to animate the TNB vectors as they move along the curve. You can also change your view of the curve with your cursor.

You Try It: Part V

The computational code is written so that all you have to do is change the initial vector function (in red) and then re-execute the commands. We suggest that you choose some of the homework problems from your text for the TNB frame, since the computation for the unit normal and unit binormal can get you very bogged down, even in Mathematica. You may also wish to change the domain over which you extend your function (red, in the second cell).

If you check out the following example, expect to wait a few minutes for the computations.

Clear[r,v,t,speed]
mag[vector_]:=(Sqrt[vector.vector])
Print["position vector is ",r[t_]={2t,Cos[t-1],Exp[-t]}]
Print["velocity vector is ",v[t_]=r'[t]]
Print["acceleration vector is ",a[t_]=v'[t]]
Print["speed is ",speed[t_]=mag[v[t]]]
Print["unit tangent vector is ",utan[t_]=v[t]/speed[t]//Simplify]
Print["curvature is ",curvature[t_]=mag[Cross[v[t],a[t]]]/((speed[t])^3)//Simplify]
Print["torsion is ",torsion[t_]=Det[{v[t],a[t],a'[t]}]/((mag[Cross[v[t],a[t]]])^2)//Simplify]
top=utan'[t]//Simplify;
bottom=mag[top]//Simplify;
Print["unit normal is ",un[t_]=(top/bottom)//Simplify]
Print["unit binormal is ",ubn[t_]=Cross[utan[t],un[t]]//Simplify]

The following set of commands will plot the unit tangent, unit normal, and unit binormal vectors as you move along the curve.

After the plot is generated, you can move the slider at the top to  animate the TNB vectors as they move along the curve. You can also change your view of the curve with your cursor.

Off[ParametricPlot3D::"ppcom"];
Manipulate[
p1=ParametricPlot3D[r[t],{t,0,2.π}];
p2=Graphics3D[{Thickness[0.02],RGBColor[1,0,0],Line[{r[t],r[t]+utan[t]}/.t->ta]}];
p3=Graphics3D[{Thickness[0.02],RGBColor[0,1,0],Line[{r[t],r[t]+un[t]}/.t->ta]}];
p4=Graphics3D[{Thickness[0.02],RGBColor[0,0,1],Line[{r[t],r[t]+ubn[t]}/.t->ta]}];
p5=Graphics3D[{Dashing[0.01],Line[{r[t]+0.20*utan[t],r[t]+0.20*utan[t]+0.20*ubn[t]}/.t->ta],Line[{r[t]+0.20*ubn[t],r[t]+0.20*ubn[t]+0.20*utan[t]}/.t->ta],Line[{r[t]+0.20*utan[t],r[t]+0.20*utan[t]+0.20*un[t]}/.t->ta],Line[{r[t]+0.20*un[t],r[t]+0.20*un[t]+0.20*utan[t]}/.t->ta],Line[{r[t]+0.20*un[t],r[t]+0.20*un[t]+0.20*ubn[t]}/.t->ta],Line[{r[t]+0.20*ubn[t],r[t]+0.20*ubn[t]+0.20*un[t]}/.t->ta],Line[{r[t]+0.20*utan[t]+0.20*ubn[t],r[t]+0.20*utan[t]+0.20*ubn[t]+0.2*un[t]}/.t->ta],Line[{r[t]+0.20*utan[t]+0.20*un[t],r[t]+0.20*utan[t]+0.20*ubn[t]+0.20*un[t]}/.t->ta],Line[{r[t]+0.20*un[t]+0.20*ubn[t],r[t]+0.20*utan[t]+0.20*ubn[t]+0.20*un[t]}/.t->ta]}];
Show[p1,p2,p3,p4,p5],{ta,0,2π,Appearance->"Labeled"},TrackedSymbols:>{ta}]

Move the slider at the top to animate the TNB vectors as they move along the curve. You can also change your view of the curve with your cursor.

Try some more problems from your text.

\[MathematicaIcon] About Mathematica

In Mathematica, the derivative can be found with either the derivative command D[function,variable to differentiate with respect to] or the prime (single quote), f'[x]. For the prime to work, the function must be defined with an argument (f[x]), whereas the differentiation command can be applied to a function in any form, with or without an argument.
Go back