restart: with(Maplets[Elements]): with(Student[Calculus1]): with(Maplets[Tools]): with(plots): with(XMLTools): ### GrafTel:=proc(Pf,Pa,Pb,ZobrTel,ZobrKr,PomOsy,fram,box,norm,zadne,OsaY) local funkce,Tel,Kr,pomer,osy: pomer:=unconstrained: osy:=boxed: if PomOsy=true then pomer:=constrained: end if: if fram=true then osy:=frame: elif norm=true then osy:=normal: elif zadne=true then osy:=none: end if: funkce:=unapply(Pf,x): if OsaY=false then Tel:=plot3d([x,cos(theta)*funkce(x),sin(theta)*funkce(x)],x=Pa..Pb,theta=0..2*Pi,style=patch, axes=osy, scaling=pomer,labels=[x,y,z]): Kr:=spacecurve([x,Pf,0],x=Pa..Pb,color=red,thickness=3,axes=osy, scaling=pomer,labels=[x,y,z]): else Tel:=plot3d([x*sin(t),x*cos(t),funkce(x)],x=Pa..Pb,t=-2*Pi..0,axes=osy,scaling=pomer,labels=[z,x,y]); Kr:=spacecurve([0,x,Pf],x=Pa..Pb,color=red,thickness=3,axes=osy,scaling=pomer,labels=[z,x,y]): end if: if (ZobrTel and ZobrKr) then display({Tel,Kr}): elif (ZobrTel=true and ZobrKr=false) then display(Tel): elif (ZobrTel=false and ZobrKr=true) then display(Kr): else textplot3d([0,0,0,`nic k zobrazeni`], axes=osy, scaling=pomer): end if: end proc: ### GrafKr:=proc(Pf,Pa,Pb,Pdel): ApproximateInt(Pf, x=Pa..Pb, method=midpoint, partition=Pdel, showarea=false, output=plot, title=""): end proc: ### ObjApr:=proc(Pf,Pa,Pb,Pdel,OsaY) local funkce,d,obj,V0,V: funkce:=unapply(Pf,x): d:=(Pb-Pa)/Pdel: if OsaY=false then obj:=Pi*d*Sum((funkce(Pa+d/2+i*d))^2,i=0..Pdel-1): evalf(obj,10): else V0:=Pi*(d^2/4)*funkce(Pa+d/2): V:=V0+sum( (Pi*funkce(Pa+d/2+i*d)) * ((Pa+d/2+i*d)^2 - (Pa+d/2+(i-1)*d)^2), i=1..Pdel-1): evalf(V,10): end if: end proc: ### iniMathML:=proc(iniEqn) MathML:-ExportPresentation(iniEqn); end proc: ### addMathML:=proc(mathMLStr,addEqn) local tree, cmc, child, children, nl, eqnSign; tree:=FromString(mathMLStr); cmc:=ContentModelCount(tree); child:=FromString(MathML:-ExportPresentation(addEqn)); children:=ContentModel(child); nl:=FromString(" "); eqnSign:=Element("mo","="); tree:=AddChild(tree,nl,cmc); tree:=AddChild(tree,eqnSign,cmc+1); for child in children do cmc:=ContentModelCount(tree); tree:=AddChild(tree,child,cmc); end do: tree:=MakeElement("mrow", [], ContentModel(tree) ): tree := Element("math", tree): ToString(tree): end proc: ### PMLVyp:=proc(Pf,Pa,Pb,OsaY) local objem,mlStr,prim: mlStr:="": if OsaY=false then mlStr:=iniMathML(VolumeOfRevolution(Pf, x=Pa..Pb, output=integral)): prim:=[int(Pi*Pf^2,x)]: objem:=VolumeOfRevolution(Pf,x=Pa..Pb): mlStr:=addMathML(mlStr, prim): mlStr:=addMathML(mlStr, objem): mlStr:=addMathML(mlStr, evalf(objem)): else mlStr:=iniMathML(VolumeOfRevolution(Pf, x=Pa..Pb, axis=vertical, output=integral)): prim:=[int(2*Pi*x*Pf,x)]: objem:=VolumeOfRevolution(Pf,x=Pa..Pb, axis=vertical): mlStr:=addMathML(mlStr, prim): mlStr:=addMathML(mlStr, objem): mlStr:=addMathML(mlStr, evalf(objem)): end if: end proc: ### PAnim:=proc(Pf,Pa,Pb,PomOsy,fram,box,norm,zadne,OsaY,ZobrTel) local fce,pomer,osy,Kr: pomer:=unconstrained: osy:=boxed: if PomOsy=true then pomer:=constrained: end if: if fram=true then osy:=frame: elif norm=true then osy:=normal: elif zadne=true then osy:=none: end if: fce:=unapply(Pf,x): if OsaY=false then if ZobrTel=true then animate3d([fce(u)*sin(t*v),u,fce(u)*cos(t*v)],u=Pa..Pb,v=-2*Pi..0,t=0..1,frames=30,axes=osy,scaling=pomer, labels=[x,z,y]): else Kr:=seq(spacecurve([x,fce(x)*cos(2*Pi*n/30),fce(x)*sin(2*Pi*n/30)],x=Pa..Pb,color=red,thickness=3),n=0..30): display(Kr,insequence=true,axes=osy,scaling=pomer,labels=[x,y,z]): end if: else if ZobrTel=true then animate3d([u*sin(t*v),u*cos(t*v),fce(u)],u=Pa..Pb,v=-2*Pi..0,t=0..1,axes=osy,scaling=pomer,frames=30, labels=[x,z,y]): else Kr:=seq(spacecurve([fce(x),x*cos(2*Pi*n/30),x*sin(2*Pi*n/30)],x=Pa..Pb,color=red,thickness=3),n=0..30): display(Kr,insequence=true,axes=osy,scaling=pomer,labels=[y,x,z]): end if: end if: end proc: ### PVymaz:=proc() Set('apr(value)'=""): Set('MLVyp(value)'=""): end proc: ### StartMaplet:=proc() local objem, StrOMapletu, StrNavod: ### StrNavod:="Tento maplet slouzi k vypoctu objemu rotacniho telesa. 1) Do prvniho radku zadejte funkci promenne x, kde: x^a - zapis a-te mocniny vyrazu x, exp(x), ln(x) - exponencialni a logaritmicka funkce, sin(x),cos(x),tan(x) - trigonometricke funkce, sinh(x),cosh(x),tanh(x) - hyperbolicke funkce. Do nasledujiciho radku zadejte interval - dolni a horni mez. Do tretiho radku zapiste pocet podintervalu intervalu [a,b]. Pomoci dvou prepinacu v okne 'Osa rotace' zvolte osu, podle ktere bude krivka rotovat. 2) Stiskem tlacitka 'Vypocitej' se provede vypocet objemu rotacniho telesa. Tlacitko 'Vykresli' slouzi k zobrazeni zadane krivky a telesa, ktere vzniklo jeji rotaci. Pomoci tlacitka 'Animace' a okna 'Ovladani animace' lze vznik telesa animovat. 3) V menu 'Nastaveni'->'Nastaveni grafu' lze nastavit vlastnosti os pri zobrazeni grafu. 4) Volba 'Maplet' -> 'Zavrit' uzavre maplet. Prislusnou teorii spolu s priklady lze nalezt ve vlastnim textu bakalarske prace.": ### StrOMapletu:=" Objem rotacniho telesa Maplet byl napsan v programu Maple 9.5 divize Maplesoft firmy Waterloo Maple inc., www.maplesoft.com. Maplet vzniknul v ramci bakalarske prace Maplety k tematu: Aplikace integralniho poctu. Zdenek Liscinsky, Prirodovedecka fakulta Masarykovy univerzity, 2006": ### objem:=Maplet('onstartup'=RunWindow('HlavniOkno'), Font['F1']('family'="Default", 'bold'='true', 'size'='11'), Font['F2']('family'="Default", 'bold'='true', 'size'='12'), Window['HlavniOkno']('resizable'='false','menubar'='HlMenu','layout'='Okno','title'="Objem rotacniho telesa"), #Window['WVzorec']('resizable'=false,'layout'='Vzorec','title'="Vypocet objemu"), Window['WNastav']('resizable'=false,'layout'='Nastav','title'="Nastaveni grafu"), Window['WNavod']('resizable'=false,'layout'='Navod','title'="Navod"), Window['Wo']('resizable'=false,'layout'='OMapletu','title'="O Mapletu"), ### ButtonGroup['BG1'](), ButtonGroup['BG2'](), ### MenuBar['HlMenu']( Menu['MSoubor']("Maplet", MenuItem("Vypocitej",'onclick'='AVypocet'), MenuItem("Vykresli",'onclick'='AGraf'), MenuItem("Animace",'onclick'='AAnim'), MenuItem("Konec",Shutdown()) ), Menu['MNastav']("Nastaveni", MenuItem("Nastaveni grafu",'onclick'=RunWindow('WNastav')) ), Menu['MNapoveda']("Napoveda", MenuItem("Navod",'onclick'=RunWindow('WNavod')), MenuItem("O mapletu", 'onclick'=RunWindow('Wo')) ) ), ### BoxLayout['Nastav']( BoxColumn( BoxRow('border'=true, 'caption'="Pomer os", CheckBox['CBPomOsy']('value'=false,'font'='F2', 'caption'="Zobrazit osy 1:1") ), BoxColumn('border'=true,'caption'="Zobrazeni os", BoxRow(RadioButton['RBnorm']("Normalni",'value'=false,'group'='BG2', 'font'='F2'), RadioButton['RBnone']("Zadne",'value'=false,'group'='BG2', 'font'='F2') ), BoxRow(RadioButton['RBbox']("Boxed",'value'=true,'group'='BG2', 'font'='F2'), RadioButton['RBframe']("Framed",'value'=false,'group'='BG2', 'font'='F2') ) ), Button("OK", CloseWindow('WNastav')) ) ), ### BoxLayout['Navod']( BoxColumn(TextBox('wrapped'=true,'width'=35,'height'=28,'editable'='false','font'='F2','value'=StrNavod), Button("OK", CloseWindow('WNavod')) ) ), ### BoxLayout['OMapletu']( BoxColumn(TextBox('wrapped'=true,'width'=40,'height'=12,'editable'='false','font'='F2', 'value'=StrOMapletu), Button("OK", CloseWindow('Wo'))) ), ### BoxLayout['Okno']( BoxRow('inset'=0, BoxColumn( BoxColumn('border'=true,'caption'="Zadani funkce f(x)", BoxRow(Label(" f ( x ) ", 'font'='F2'), Label("=", 'font'='F2'), TextField['f']("sqrt(1-x^2)",15,'tooltip'="sem zapis funkci promenne x") ), BoxRow(HorizontalGlue(), Label("Interval:"), Label("a",'font'='F2'), Label("=",'font'='F2'), TextField['a']("-1",3,'tooltip'="dolni mez"), Label("..."), Label("b",'font'='F2'), Label("=",'font'='F2'), TextField['b']("1",3,'tooltip'="horni mez"), HorizontalGlue() ), BoxRow(Label(" Deleni intervalu:"), Label("n", 'font'='F2'), Label("=",'font'='F2'), TextField['del']("8",3,'tooltip'="sem zapis pocet deleni intervalu"), HorizontalGlue() ) ), BoxRow('border'=true,'caption'="Osa rotace",'inset'=0,'spacing'=0, RadioButton['RBx']("podle osy x",'value'=true,'group'='BG1', 'font'='F2','onclick'='AVymaz'), RadioButton['RBy']("podle osy y",'value'=false,'group'='BG1', 'font'='F2','onclick'='AVymaz') ), BoxRow('border'=true, 'caption'="Zobrazeni grafu", 'inset'=0, 'spacing'=0, CheckBox['CBTel']('value'=true, 'caption'="zobrazit teleso"), CheckBox['CBKr']('value'=true, 'caption'="zobrazit krivku") ), BoxRow(Button("Vypocitej", 'onclick'='AVypocet'), Button("Vykresli", 'onclick'='AGraf'), Button("Animace", 'onclick'='AAnim') ), #BoxRow(Button("Konec", Shutdown()) #), BoxColumn('border'=true, 'caption'="Ovladani animace", 'inset'=0, 'spacing'=0, BoxRow( Button['BPlay'](" Play",SetOption(gr('play')=true), 'tooltip'="spusti animaci"), Button['BPause']("Pause",SetOption(gr('pause')=true), 'tooltip'="pozastavi animaci"), Button['BStop']("Stop",SetOption(gr('`stop`')=true), 'tooltip'="zastavi animaci") ), BoxRow(Button['BVzad']("Vzad",SetOption(gr('frame_backwards')=true), 'tooltip'="o krok vzad"), Button['BVpred']("Vpred",SetOption(gr('frame_forward')=true), 'tooltip'="o krok vpred"), CheckBox['CBopak'](caption="opakovat", 'onchange'=SetOption('target'='gr', `option` ='continuous', Argument(CBopak)), 'tooltip'="opakovat animaci") ) ), BoxColumn('border'=true, 'caption'="Objem telesa", BoxRow(Label("Aproximace:"), TextField['apr']('editable'=false,'width'=11, 'tooltip'="Objem vypocteny aproximaci") ), BoxColumn(Label("Vypocet integralu:", 'tooltip'="posledni radek v okne vypoctu vycisluje symbolicke hodnoty s presnosti na 10 cislic"), MathMLViewer['MLVyp']('height'=220,'width'=250,'fontsize'='16') ) ) ), #konec 1. sloupce BoxColumn( BoxRow('border'=true,'caption'="Graf", Plotter['gr']('continuous'=false) ), BoxRow('border'=true, 'caption'="Krivka", Plotter['kr']('height'=255,'width'=360) ) ) # konec 2.sloupce ) # konec BoxRow ), # konec BoxLayout ### Action['AGraf'](Evaluate('target'='gr', 'function'='GrafTel', Argument('f'), Argument('a'), Argument('b'), Argument(CBTel), Argument(CBKr), Argument(CBPomOsy), Argument(RBframe), Argument(RBbox), Argument(RBnorm), Argument(RBnone), Argument(RBy) ), Evaluate('target'='kr', 'function'='GrafKr', Argument('f'), Argument('a'), Argument('b'), Argument('del') ) ), ### Action['AVypocet'](Evaluate('target'='apr', 'function'='ObjApr', Argument('f'), Argument('a'), Argument('b'), Argument('del'), Argument(RBy) ), Evaluate('target'='MLVyp', 'function'='PMLVyp', Argument('f'), Argument('a'), Argument('b'), Argument(RBy) ) ), ### Action['AAnim'](Evaluate('target'='gr', 'function'='PAnim', Argument('f'), Argument('a'), Argument('b'), Argument(CBPomOsy), Argument(RBframe), Argument(RBbox), Argument(RBnorm), Argument(RBnone), Argument(RBy), Argument(CBTel) ) ), ### Action['AVymaz'](Evaluate('function'='PVymaz') ) ): #Maplet Maplets:-Display(objem): end proc: #StartMaplet StartMaplet(): # Warning, the name changecoords has been redefined # Warning, the names AddAttribute and Print have been rebound