Direction of a Cross Product using the Right Hand Rule
Programmers: Travis Lamb & Shannon Murray
Math 253 Honors Section 201
Fall 2012
Instructor: Philip Yasskin
restart:
with(plots):
with(Maplets[Tools]):
with(Maplets[Elements]):
StartEngine();
randomize():
lightcyan:="#DDFFFF":
GetVersion:=proc()
local S, S1, S3, S4;
options `Copyright 2009-10, Philip B. Yasskin and Douglas B. Meade, Maplets for Calculus`;
uses StringTools;
S:=interface(version);
S:=map( Trim, Split( S, "," ) );
S1:=Split(S[1], " " );
S3:=Split(S[3], " " );
S4:=Split(S[-1], " " );
sprintf("%s (%s)", S[2],S3[-1]);
end proc:
rand10:=rand(1..10):
vectorNames:=["North", "South", "East", "West", "Up", "Down",
"NorthEast", "SouthEast", "SouthWest", "NorthWest", "No Direction"]:
vectors:= [[0,1,0], [0,-1,0], [1,0,0], [-1,0,0], [0,0,1], [0,0,-1],
[1/sqrt(2),1/sqrt(2),0], [1/sqrt(2),-1/sqrt(2),0], [-1/sqrt(2),-1/sqrt(2),0], [-1/sqrt(2),1/sqrt(2),0], [0,0,0]]:
ask:=proc()
global u, v, uxv, uxvName, mainPlotDisplay;
local uIndex,vIndex,uxvIndex,uName,vName, xAxis, yAxis, zAxis, northLabel, southLabel, eastLabel, westLabel, upLabel, downLabel,uxvLength;
uIndex:=rand10();
vIndex:=rand10();
u:=vectors[uIndex];
uName:=vectorNames[uIndex];
v:=vectors[vIndex];
vName:=vectorNames[vIndex];
uxv:=[0,0,0];
uxv[1]:=u[2]*v[3]-u[3]*v[2];
uxv[2]:=u[3]*v[1]-u[1]*v[3];
uxv[3]:=u[1]*v[2]-u[2]*v[1];
uxvLength:=sqrt(uxv[1]^2 + uxv[2]^2 + uxv[3]^2);
if uxvLength<>0 then
uxv[1]:=uxv[1]/uxvLength;
uxv[2]:=uxv[2]/uxvLength;
uxv[3]:=uxv[3]/uxvLength;
end if;
member(uxv, vectors, 'uxvIndex');
uxvName:=vectorNames[uxvIndex];
Set(uDirectionTF=uName);
Set(vDirectionTF=vName);
xAxis:=spacecurve([[-1,0,0],[1,0,0]], color=black);
yAxis:=spacecurve([[0,-1,0],[0,1,0]], color=black);
zAxis:=spacecurve([[0,0,-1],[0,0,1]], color=black);
northLabel:=textplot3d([0,1.2,0, "North"]);
southLabel:=textplot3d([0,-1.2,0, "South"]);
eastLabel:=textplot3d([1.2,0,0, "East"]);
westLabel:=textplot3d([-1.2,0,0, "West"]);
upLabel:=textplot3d([0,0,1.2, "Up"]);
downLabel:=textplot3d([0,0,-1.2, "Down"]);
mainPlotDisplay:=display(xAxis, yAxis, zAxis,
northLabel, southLabel, eastLabel, westLabel, upLabel, downLabel,
orientation=[-75,75,1]);
Set(mainPlot=mainPlotDisplay);
Set(dropDown="");
Set(smallReply="", smallReply(background)=white);
Set(reply="", reply(background)=white);
Set(hintButton(enabled)=true);
Set(checkButton(enabled)=true);
Set(showButton(enabled)=true);
end proc:
hint:=proc()
global mainPlotDisplay;
local mainPlotDisplay2, uArrow, vArrow;
Set(smallReply="Hint",
smallReply(background)=Orange, smallReply(foreground)=black);
Set(reply="In the plot, the direction of u is red and v is blue.",
reply(background)=Orange, reply(foreground)=black);
uArrow:=arrow(Vector([0,0,0]), Vector(u), color=red);
vArrow:=arrow(Vector([.01,.01,.01]), Vector(v+[.01,.01,.01]), color=blue);
mainPlotDisplay2:=display(mainPlotDisplay, uArrow, vArrow, orientation=[-75,75,1]);
Set(mainPlot=mainPlotDisplay2);
end proc:
check:=proc()
global uxvName, mainPlotDisplay;
local userName, mainPlotDisplay2, uArrow, vArrow, uxvArrow;
userName:=Get(dropDown):
if userName=uxvName then
Set(smallReply="Correct!",
smallReply(background)=green, smallReply(foreground)=black);
Set(reply="You're great! The direction of u is red, v is blue, and u x v is magenta. Try another one.",
reply(background)=green, reply(foreground)=black);
uArrow:=arrow(Vector([0,0,0]), Vector(u), color=red);
vArrow:=arrow(Vector([.01,.01,.01]), Vector(v+[.01,.01,.01]), color=blue);
uxvArrow:=arrow(Vector([0,0,0]), Vector(uxv), color=magenta);
mainPlotDisplay2:=display(mainPlotDisplay, uArrow, vArrow, uxvArrow, orientation=[-75,75,1]);
Set(mainPlot=mainPlotDisplay2);
else
Set(smallReply="Incorrect.",
smallReply(background)=red, smallReply(foreground)=white);
Set(reply="Read the hint and try again.",
reply(background)=red, reply(foreground)=white);
end if;
end proc:
show:=proc()
global uxvName, mainPlotDisplay;
local mainPlotDisplay2, uArrow, vArrow, uxvArrow;
uArrow:=arrow(Vector([0,0,0]), Vector(u), color=red);
vArrow:=arrow(Vector([.01,.01,.01]), Vector(v+[.01,.01,.01]), color=blue);
uxvArrow:=arrow(Vector([0,0,0]), Vector(uxv), color=magenta);
mainPlotDisplay2:=display(mainPlotDisplay, uArrow, vArrow, uxvArrow, orientation=[-75,75,1]);
Set(mainPlot=mainPlotDisplay2);
Set(smallReply="Shown.",
smallReply(background)=yellow, smallReply(foreground)=black);
Set(reply="The direction of u is red, v is blue, and u x v is magenta. Try on your own next time.",
reply(background)=yellow, reply(foreground)=black);
Set(dropDown=uxvName);
end proc:
FindSlope:=Maplet(onstartup = RunWindow(MAIN),
Window[MAIN](title="Direction of a Cross Product using the Right Hand Rule",
[ [ halign=none,
Button("New Problem", Evaluate(function = "ask"), background=magenta),
HorizontalGlue(),
Button("Quit", Shutdown(), background=pink)
],
BoxColumn( valign=none, border=true,
caption="Goal:",
[ halign=none,
"If u is pointing ",
TextField[uDirectionTF](width=8, editable=false,
background=white, halign=center),
"and v is pointing ",
TextField[vDirectionTF](width=8, editable=false,
background=white, halign=center),
HorizontalGlue()
],
[ halign = none,
"in which direction is u cross v pointing? ",
DropDownBox[dropDown](["", "North", "South", "East", "West", "Up", "Down",
"NorthEast", "SouthEast", "SouthWest", "NorthWest", "No Direction"],
width=110, background=turquoise, halign=center),
HorizontalGlue()
]
),
[
[ valign=none,
VerticalGlue(),
Button[hintButton]("Hint", Evaluate(function = "hint"),
width=75, background=Orange, enabled=false),
Button[checkButton]("Check", Evaluate(function = "check"),
width=75, background=green, enabled=false),
TextField[smallReply](width=5, editable=false,
background=white, halign=center),
Button[showButton]("Show", Evaluate(function = "show"),
width=75, background=yellow, enabled=false),
VerticalGlue()
],
[ valign=none, inset=0, border=true,
caption="Plot:",
[ background=tan,
Plotter[mainPlot](width=300, height=300)
]
]
],
[ TextBox[reply](width=50, height=2, editable=false, background=white)
],
BoxColumn( halign=none, background=lightcyan, inset=0, spacing=0,
[ background=lightcyan, inset=0, spacing=0,
Label("Programmers: D.B. Meade & P.B. Yasskin", font=Font("helvetica",10)),
HorizontalGlue(),
Label("\302\251 Copyright: Maplets for Calculus 2006-12", font=Font("helvetica",10))
],
[ halign=none,
"Instructor: Philip Yasskin",
HorizontalGlue(),
"Programmers: Travis Lamb and Shannon Murray",
HorizontalGlue(),
"Copyright 2012, P. Yasskin"
]
)
]
)
):
Maplets[Display]( FindSlope );