Parametric and Symmetric Equations of a Line in 3D given 2 Points
Programmers: Garret Mai & Danielle Cope
Math 253 Honors Section 202
Fall 2012
Instructor: Philip Yasskin
restart:
with(Maplets[Tools]):
with(Maplets[Elements]):
StartEngine();
randomize():
TEXTLprogrammers:=
"Programmers: D.B. Meade & P.B. Yasskin":
TEXTLasstprogrammer:=
"Assistant Programmers: Garret Mai & Danielle Cope":
TEXTLcopyright:=
"\302\251 Copyright: Maplets for Calculus 2006-10":
TEXTLversion:=
"M4C v1.3.2 2012":
FontFooter:=Font("helvetica",10):
FontSymbol:=Font("symbol",12):
FontBig:=Font("times",20):
LIBLogo:=cat(libname,"/M4C/M4C.png"):
Logo:="M4C.png":
ColorFooter:=cyan:
ColorMessage:=white:
ColorMessageFrgd:=black:
ColorBkgd:=wheat:
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:
rand5:=rand(-5..5):
ask:=proc()
global vecPQ,
parametricx1, parametricy1, parametricz1,
symmetricx1, symmetricy1, symmetricz1,
parametricx2, parametricy2, parametricz2,
symmetricx2, symmetricy2, symmetricz2;
local a0,b0,c0,d0,e0,f0;
a0:=rand5();
b0:=rand5();
c0:=rand5();
d0:=rand5();
while d0=a0 do
d0:=rand5();
end do;
e0:=rand5();
while e0=b0 do
e0:=rand5();
end do;
f0:=rand5();
while f0=c0 do
f0:=rand5();
end do;
vecPQ:=[d0-a0,e0-b0,f0-c0];
parametricx1:= a0+(d0-a0)*t;
parametricy1:= b0+(e0-b0)*t;
parametricz1:= c0+(f0-c0)*t;
parametricx2:= d0+(d0-a0)*t;
parametricy2:= e0+(e0-b0)*t;
parametricz2:= f0+(f0-c0)*t;
symmetricx1:= (x-a0)/(d0-a0);
symmetricy1:= (y-b0)/(e0-b0);
symmetricz1:= (z-c0)/(f0-c0);
symmetricx2:= (x-d0)/(d0-a0);
symmetricy2:= (y-e0)/(e0-b0);
symmetricz2:= (z-f0)/(f0-c0);
Set(reply(background)=white, reply(foreground)=white);
Set(TFPQ="");
Set(replyPQ="", replyPQ(background)=white);
Set(TFparamx="");
Set(TFparamy="");
Set(TFparamz="");
Set(replyparam="", replyparam(background)=white);
Set(TFsymmx="");
Set(TFsymmy="");
Set(TFsymmz="");
Set(replysymm=" ",replysymm(background)=white);
Set(question= sprintf("Find the parametric and symmetric equations of the line through the points\134n P = (%a,%a,%a) and Q = (%a,%a,%a).",
a0,b0,c0,d0,e0,f0
));
Set(BCkPQ(enabled)=true);
Set(BShPQ(enabled)=true);
Set(BCkparam(enabled)=false);
Set(BShparam(enabled)=false);
Set(BCksymm(enabled)=false);
Set(BShsymm(enabled)=false);
end proc:
hintPQ:=proc()
Set(reply="Find the vector by subtracting the points [Qx-Px,Qy-Py,Qz-Pz]",
reply(background)="Orange", reply(foreground)=black);
Set(replyPQ="", replyPQ(background)=white);
end proc:
checkPQ:=proc()
global vecPQ;
local uservec;
uservec:=Get(TFPQ::list, corrections=true, update=true):
if uservec=vecPQ then
Set(reply="Correct! Keep going.",
reply(background)=green, reply(foreground)=black);
Set(replyPQ="correct",
replyPQ(background)=green, replyPQ(foreground)=black);
Set(BCkparam(enabled)=true);
Set(BShparam(enabled)=true);
elif uservec=-vecPQ then
Set(reply="You computed QP instead of PQ. Fix it and check it again.",
reply(background)="Orange", reply(foreground)=black);
Set(replyPQ="almost",
replyPQ(background)="Orange", replyPQ(foreground)=black);
else
Set(reply="Incorrect. Try again.",reply(background)=red, reply(foreground)=white);
Set(replyPQ="incorrect", replyPQ(background)=red, replyPQ(foreground)=white);
end if;
end proc:
showPQ:=proc()
global vecPQ;
Set(TFPQ=vecPQ):
Set(reply="Next time try doing it yourself.",
reply(background)=yellow, reply(foreground)=black);
Set(replyPQ="shown",
replyPQ(background)=yellow, replyPQ(foreground)=black);
Set(BCkparam(enabled)=true);
Set(BShparam(enabled)=true);
end proc:
hintparam:=proc()
Set(reply="The three equations are the components of X = P + t*v.\134nRemember to use only P or only Q as your point.",
reply(background)="Orange", reply(foreground)=black);
Set(replyparam="", replyparam(background)=white);
end proc:
checkparam:=proc()
global parametricx1, parametricx2, parametricy1, parametricy2, parametricz1, parametricz2;
local userparametricx,userparametricy,userparametricz;
userparametricx:=Get(TFparamx::linear(t), corrections=true, update=true):
userparametricy:=Get(TFparamy::linear(t), corrections=true, update=true):
userparametricz:=Get(TFparamz::linear(t), corrections=true, update=true):
if
( userparametricx=parametricx1
and userparametricy=parametricy1
and userparametricz=parametricz1
)
or
( userparametricx=parametricx2
and userparametricy=parametricy2
and userparametricz=parametricz2
) then
Set(reply="Correct! Keep going.",
reply(background)=green, reply(foreground)=black);
Set(replyparam="correct",
replyparam(background)=green, replyparam(foreground)=black);
Set(BCksymm(enabled)=true);
Set(BShsymm(enabled)=true);
else
Set(reply="Incorrect. Try again.",
reply(background)=red, reply(foreground)=white);
Set(replyparam="incorrect",
replyparam(background)=red, replyparam(foreground)=white);
end if;
end proc:
showparam:=proc()
global parametricx1, parametricy1,parametricz1;
Set(TFparamx=parametricx1):
Set(TFparamy=parametricy1):
Set(TFparamz=parametricz1):
Set(reply="Next time try doing it yourself.",
reply(background)=yellow, reply(foreground)=black);
Set(replyparam="shown",
replyparam(background)=yellow, replyparam(foreground)=black);
Set(BCksymm(enabled)=true);
Set(BShsymm(enabled)=true);
end proc:
hintsymm:=proc()
Set(reply="Solve each parametric equation for t.\134nRemember to use only P or only Q as your point.",
reply(background)="Orange", reply(foreground)=black);
Set(replysymm="", replysymm(background)=white);
end proc:
checksymm:=proc()
global symmetricx1, symmetricx2, symmetricy1, symmetricy2, symmetricz1, symmetricz2;
local usersymmetricx,usersymmetricy,usersymmetricz;
usersymmetricx:=Get(TFsymmx::linear(x), corrections=true, update=true):
usersymmetricy:=Get(TFsymmy::linear(y), corrections=true, update=true):
usersymmetricz:=Get(TFsymmz::linear(z), corrections=true, update=true):
if ( usersymmetricx=symmetricx1
and usersymmetricy=symmetricy1
and usersymmetricz=symmetricz1
)
or
( usersymmetricx=symmetricx2
and usersymmetricy=symmetricy2
and usersymmetricz=symmetricz2
) then
Set(reply="Correct! Keep going.",
reply(background)=green, reply(foreground)=black);
Set(replysymm="correct",
replysymm(background)=green, replysymm(foreground)=black);
else
Set(reply="Incorrect. Try again.",
reply(background)=red, reply(foreground)=white);
Set(replysymm="incorrect",
replysymm(background)=red, replysymm(foreground)=white);
end if;
end proc:
showsymm:=proc()
global symmetricx1, symmetricy1, symmetricz1;
Set(TFsymmx=symmetricx1):
Set(TFsymmy=symmetricy1):
Set(TFsymmz=symmetricz1):
Set(reply="Next time try doing it yourself.",
reply(background)=yellow, reply(foreground)=black);
Set(replysymm="shown",
replysymm(background)=yellow, replysymm(foreground)=black);
end proc:
FindPSEquations:=Maplet(onstartup = RunWindow(MAIN),
Window[MAIN](title="Parametric and Symmetric Equations of a Line in 3D given 2 Points",
[
[ halign=none,
Button("New Problem", Evaluate(function = "ask"), background=magenta),
HorizontalGlue(),
TextBox[question](width=42, height=3, editable=false, background=white),
HorizontalGlue(),
Button("Quit", Shutdown(), background=pink)
],
[ halign=none, border=true,
caption="Step 1: Form the vector from P to Q: ",
"PQ =",
TextField[TFPQ](width=15, background=turquoise),
HorizontalGlue(),
Button[BHtPQ]("Hint", Evaluate(function = "hintPQ"), background="Orange"),
Button[BCkPQ]("Check", Evaluate(function = "checkPQ"), background=green, enabled=false),
TextField[replyPQ](width=6, background=white),
Button[BShPQ]("Show", Evaluate(function = "showPQ"), background=yellow, enabled=false)
],
[ halign=none, border=true,
caption="Step 2: Find the parametric equation of the line: ",
"x =",
TextField[TFparamx](width=8, background=turquoise),
HorizontalGlue(),
"y =",
TextField[TFparamy](width=8, background=turquoise),
HorizontalGlue(),
"z =",
TextField[TFparamz](width=8, background=turquoise),
HorizontalGlue(),
Button[BHtparam]("Hint", Evaluate(function = "hintparam"), background="Orange"),
Button[BCkparam]("Check", Evaluate(function = "checkparam"), background=green, enabled=false),
TextField[replyparam](width=6, background=white),
Button[BShparam]("Show", Evaluate(function = "showparam"), background=yellow, enabled=false)
],
BoxColumn( valign=none, inset=0, spacing=0, border=true,
caption="Step 3: Find the symmetric equation of the line:",
[ halign=left,
" From x:",
" From y:",
" From z:",
HorizontalGlue(),
HorizontalGlue()
],
[ halign=none,
"t =",
TextField[TFsymmx](width=9, background=turquoise),
" = ",
TextField[TFsymmy](width=9, background=turquoise),
" = ",
TextField[TFsymmz](width=9, background=turquoise),
HorizontalGlue(),
Button[BHtsymm]("Hint", Evaluate(function = "hintsymm"), background="Orange"),
Button[BCksymm]("Check", Evaluate(function = "checksymm"), background=green, enabled=false),
TextField[replysymm](width=6, background=white),
Button[BShsymm]("Show", Evaluate(function = "showsymm"), background=yellow, enabled=false)
]
),
BoxRow( halign=none, background=ColorBkgd,
TextBox[reply](width=60, height=2, editable=false, background=ColorMessage),
Label(Image(Logo)),
Label(Image(LIBLogo))
),
BoxColumn( halign=none, background=ColorFooter, inset=0, spacing=0,
[ background=ColorFooter, inset=0, spacing=0,
Label(TEXTLprogrammers, font=FontFooter),
HorizontalGlue(),
Label(TEXTLcopyright, font=FontFooter),
HorizontalGlue(),
Label(TEXTLversion, font=FontFooter)
],
[ halign=none,
"Instructor: Philip Yasskin",
HorizontalGlue(),
"Programmers: Garret Mai & Danielle Cope",
HorizontalGlue(),
"Copyright 2012, P. Yasskin"
]
)
]
)
):
Maplets[Display]( FindPSEquations );