{VERSION 5 0 "IBM INTEL NT" "5.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Text Output" -1 2 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 0 0 0 0 0 1 3 0 3 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 2 6 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 2 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Warning" -1 7 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 2 2 2 2 2 1 1 1 3 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Title" 0 18 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 1 0 0 0 0 0 0 0 }3 0 0 -1 12 12 0 0 0 0 0 0 19 0 }{PSTYLE "Author" 0 19 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 8 8 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 18 "" 0 "" {TEXT -1 33 "Two-Body Gravitational At traction" }}{PARA 19 "" 0 "" {TEXT -1 50 "By Sylvain Muise, smuise@stu dent.math.uwaterloo.ca" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 109 "This m aplet displays the 2-D or 3-D paths over time of two masses under the \+ influence of gravitational force." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT 256 96 "To run this maplet, click the \"E xecute-Worksheet\" button in the tool-bar menu (the !!! button)\n" } {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 83 "restart: wi th(LinearAlgebra): with(plots): with(Maplets): with(Maplets[Elements]) :\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 6648 "gravityMaplet := Maplet(on startup = RunWindow(W1),\n Window[W1]('title' = \"Gravity\", menubar= MB1, 'layout' = BL1),\n Window[W2]('title' = \"Gravity2D\", menubar=M B2, 'layout' = BL2),\n Window[W3]('title' = \"Gravity3D\", menubar=MB 2, 'layout' = BL3),\n MenuBar[MB1](Menu(\"File\", MenuItem(\"Close\", Shutdown()))),\n MenuBar[MB2](Menu(\"File\", MenuItem(\"Close\", Shu tdown()))),\n BoxLayout[BL1](inset=0,\n BoxColumn(inset=0, spacing =0,\n \"Select a Dimension:\",\n Button(\"2D\",RunWindow(W2) ),\n Button(\"3D\",RunWindow(W3))\n )\n ),\n BoxLayout[BL2]( inset=0,\n BoxColumn(inset=0,\n Plotter[P12D]()\n ),\n B oxColumn(inset=0,\n BoxRow(inset=0, border=true, caption=\"Parame ters\", spacing=0,\n BoxColumn(inset=0, spacing=0,\n \+ \"Total Time:\",\n TextField[Time2D](5,\"6\"), \n \" Gravity Constant:\",\n TextField[G2D](5,\"1\")\n )\n \+ ),\n BoxRow(inset=0,border=true,caption=\"Particle 1 (Red)\", spacing=0,\n BoxColumn(inset=0,spacing=0,\n BoxRow(ins et=0,spacing=0,\n \"Mass:\",\n TextField[Mass12D ](4,\"1\")\n )\n ),\n BoxColumn(inset=0,spacing =0,\n BoxRow(inset=0,spacing=0,\n \"X:\",\n \+ TextField[X_12D](4,\"1\")\n ),\n BoxRow(inset=0 ,spacing=0,\n \"Y:\",\n TextField[Y_12D](4,\"0\" )\n )\n ),\n BoxColumn(inset=0,spacing=0,\n \+ BoxRow(inset=0,spacing=0,\n \"DX/DT:\",\n \+ TextField[DX_12D](4,\"-1/2\")\n ),\n BoxRow(inset=0, spacing=0,\n \"DY/DT:\",\n TextField[DY_12D](4, \"3/4\")\n )\n )\n ),\n BoxRow(inset=0,borde r=true, caption=\"Particle 2 (Blue)\",spacing=0,\n BoxColumn(in set=0,spacing=0,\n BoxRow(inset=0,spacing=0,\n \"M ass:\",\n TextField[Mass22D](4,\"2\")\n )\n \+ ),\n BoxColumn(inset=0,spacing=0,\n BoxRow(inset=0,sp acing=0,\n \"X:\",\n TextField[X_22D](4,\"-1/2\" )\n ),\n BoxRow(inset=0,spacing=0,\n \"Y: \",\n TextField[Y_22D](4,\"0\")\n )\n ),\n \+ BoxColumn(inset=0,spacing=0,\n BoxRow(inset=0,spacing= 0,\n \"DX/DT:\",\n TextField[DX_22D](4,\"1/4\") \n ),\n BoxRow(inset=0,spacing=0,\n \"DY/ DT:\",\n TextField[DY_22D](4,\"-3/8\")\n )\n \+ )\n ),\n BoxRow(inset=0,border=true, spacing=0, caption=\" View\",\n BoxColumn(inset=0, spacing=0,\n BoxRow(inset =0, spacing=0,\n \"Neg X:\",\n TextField[NEGX2D] (4,\"-1.5\"),\n \"Pos X:\",\n TextField[POSX2D]( 4,\"1.5\")\n ),\n BoxRow(inset=0, spacing=0,\n \+ \"Neg Y:\",\n TextField[NEGY2D](4,\"-1.5\"),\n \+ \"Pos Y:\",\n TextField[POSY2D](4,\"1.5\")\n \+ )\n )\n ),\n BoxRow(inset=0, spacing=0,\n Butt on(\"Do It!\", Evaluate(P12D = 'gravity2D(Mass12D, Mass22D, G2D, X_12D , Y_12D, X_22D, Y_22D, DX_12D, DY_12D, DX_22D, DY_22D, Time2D, NEGX2D, POSX2D, NEGY2D, POSY2D)'))\n )\n )\n ),\n BoxLayout[BL3](in set=0,\n BoxColumn(inset=0,spacing=0,\n BoxRow(inset=0, spacin g=0,\n Plotter[P13D](),\n Slider[PHI3D](lower=-180,fille d=true,majorticks=30,minorticks=10,orientation=vertical,snapticks=fals e,upper=180,value=45)\n ),\n Slider[THETA3D](lower=-180,fill ed=true,majorticks=30,minorticks=10,orientation=horizontal,snapticks=f alse,upper=180,value=-140)\n ),\n BoxColumn(inset=0,\n BoxR ow(inset=0, border=true,caption=\"Parameters\",spacing=0,\n Box Column(inset=0, spacing=0,\n \"Total Time:\",\n Text Field[Time3D](5,\"6\"),\n \"Gravity Constant:\",\n T extField[G3D](5,\"1\")\n )\n ),\n BoxRow(inset=0,bord er=true,caption=\"Particle 1 (Red)\",spacing=0,\n BoxColumn(ins et=0,spacing=0,\n BoxRow(inset=0,spacing=0,\n \"Ma ss:\",\n TextField[Mass13D](4,\"1\")\n )\n \+ ),\n BoxColumn(inset=0,spacing=0,\n BoxRow(inset=0,spa cing=0,\n \"X:\",\n TextField[X_13D](4,\"1\")\n \+ ),\n BoxRow(inset=0,spacing=0,\n \"Y:\", \n TextField[Y_13D](4,\"0\")\n ),\n BoxRo w(inset=0, spacing=0,\n \"Z:\",\n TextField[Z_13 D](4,\"1\")\n )\n ),\n BoxColumn(inset=0,spacin g=0,\n BoxRow(inset=0,spacing=0,\n \"DX/DT:\",\n \+ TextField[DX_13D](4,\"-1/2\")\n ),\n BoxRo w(inset=0,spacing=0,\n \"DY/DT:\",\n TextField[D Y_13D](4,\"3/4\")\n ),\n BoxRow(inset=0, spacing=0, \n \"DZ/DT:\",\n TextField[DZ_13D](4,\"-1/4\")\n )\n )\n ),\n BoxRow(inset=0,border=true, ca ption=\"Particle 2 (Blue)\",spacing=0,\n BoxColumn(inset=0,spac ing=0,\n BoxRow(inset=0,spacing=0,\n \"Mass:\",\n \+ TextField[Mass23D](4,\"2\")\n )\n ),\n \+ BoxColumn(inset=0,spacing=0,\n BoxRow(inset=0,spacing=0,\n \"X:\",\n TextField[X_23D](4,\"-1/2\")\n \+ ),\n BoxRow(inset=0,spacing=0,\n \"Y:\",\n \+ TextField[Y_23D](4,\"0\")\n ),\n BoxRow(inset =0, spacing=0,\n \"Z:\",\n TextField[Z_23D](4,\" -1/2\")\n )\n ),\n BoxColumn(inset=0,spacing=0, \n BoxRow(inset=0,spacing=0,\n \"DX/DT:\",\n \+ TextField[DX_23D](4,\"1/4\")\n ),\n BoxRow(ins et=0,spacing=0,\n \"DY/DT:\",\n TextField[DY_23D ](4,\"-3/8\")\n ),\n BoxRow(inset=0, spacing=0, \n \+ \"DZ/DT:\",\n TextField[DZ_23D](4,\"1/8\")\n \+ )\n )\n ),\n BoxRow(inset=0,border=true, spacing =0, caption=\"View\",\n BoxColumn(inset=0, spacing=0,\n \+ BoxRow(inset=0, spacing=0,\n \"Neg X:\",\n Tex tField[NEGX3D](4,\"-1.5\"),\n \"Pos X:\",\n Text Field[POSX3D](4,\"1.5\")\n ),\n BoxRow(inset=0, spac ing=0,\n \"Neg Y:\",\n TextField[NEGY3D](4,\"-1. 5\"),\n \"Pos Y:\",\n TextField[POSY3D](4,\"1.5 \")\n ),\n BoxRow(inset=0, spacing=0,\n \+ \"Neg Z:\",\n TextField[NEGZ3D](4,\"-1.5\"),\n \+ \"Pos Z:\",\n TextField[POSZ3D](4,\"1.5\")\n )\n \+ )\n ),\n BoxRow(inset=0, spacing=0,\n Button(\" Do It!\", Evaluate(P13D = 'gravity3D(Mass13D, Mass23D, G3D, X_13D, Y_1 3D, Z_13D, X_23D, Y_23D, Z_23D, DX_13D, DY_13D, DZ_13D, DX_23D, DY_23D , DZ_23D, Time3D, NEGX3D, POSX3D, NEGY3D, POSY3D, NEGZ3D, POSZ3D, THET A3D, PHI3D)'))\n )\n )\n )\n ):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3479 "gravity3D := proc(m1,m2,c,X1,Y1,Z1,X2,Y2,Z2,dX1,dY1 ,dZ1,dX2,dY2,dZ2,T, negX, posX, negY, posY, negZ, posZ, Th, Ph)\n loc al r1, r2, r12, M, DE1, DEx1, DEy1, DEz1, DE2, DEx2, DEy2, DEz2, diffe qs, funcs, initconds, sol, solx1, soly1, solz1, solx2, soly2, solz2, p lot1, plot2, point1, point2:\n r1 := t -> Vector([x1(t),y1(t),z1(t)]) :\n r2 := t -> Vector([x2(t),y2(t),z2(t)]):\n r12 := t -> r2(t) - r1 (t):\n M := v -> sqrt(DotProduct(v,v)):\n DE1 := m1 * (map(diff,r1(t ),t$2)) = simplify(c * m1 * m2/(M(r12(t))^2) * (r12(t))/(M(r12(t)) )):\n DEx1 := lhs(DE1)[1] = rhs(DE1)[1]:\n DEy1 := lhs(DE1)[2] = rhs (DE1)[2]:\n DEz1 := lhs(DE1)[3] = rhs(DE1)[3]:\n DE2 := m2*(map(diff ,r2(t),t$2)) = simplify(c*m2*m1/(M(r12(t))^2)* (-r12(t))/(M(r12(t)))): \n DEx2 := lhs(DE2)[1] = rhs(DE2)[1]:\n DEy2 := lhs(DE2)[2] = rhs(DE 2)[2]:\n DEz2 := lhs(DE2)[3] = rhs(DE2)[3]:\n diffeqs := DEx1, DEy1, DEz1, DEx2, DEy2, DEz2:\n funcs := x1(t), y1(t), z1(t), x2(t), y2(t) , z2(t):\n initconds := x1(0)=X1, y1(0)=Y1, z1(0)=Z1, x2(0)=X2, y2(0) =Y2, z2(0)=Z2, D(x1)(0)=dX1, D(y1)(0)=dY1, D(z1)(0)=dZ1, D(x2)(0)=dX 2, D(y2)(0)=dY2, D(z2)(0)=dZ2:\n sol := dsolve(\{diffeqs,initconds\}, \{funcs\},numeric):\n solx1 := s -> subs(sol(s),x1(t)):\n soly1 := s -> subs(sol(s),y1(t)):\n solz1 := s -> subs(sol(s),z1(t)):\n solx2 \+ := s -> subs(sol(s),x2(t)):\n soly2 := s -> subs(sol(s),y2(t)):\n so lz2 := s -> subs(sol(s),z2(t)):\n setoptions3d(view=[negX..posX,negY. .posY,negZ..posZ],scaling=constrained, axes=framed, labels=[\"x\",\"y \",\"z\"]):\n plot1 := spacecurve(['solx1(t)','soly1(t)','solz1(t)'], t=0..T,color=red):\n plot2 := spacecurve(['solx2(t)','soly2(t)','solz 2(t)'],t=0..T,color=blue):\n point1 := pointplot3d([solx1(T),soly1(T) ,solz1(T)], style=point, symbol=diamond, symbolsize=29, color=red): \n point2 := pointplot3d([solx2(T),soly2(T),solz2(T)], style=point, s ymbol=diamond, symbolsize=29, color=blue):\n display([plot1, plot2, p oint1, point2], orientation=[Th,Ph]);\nend proc:\n\ngravity2D := proc( m1,m2,c,X1,Y1,X2,Y2,dX1,dY1,dX2,dY2,T, negX, posX, negY, posY)\n loca l r1, r2, r12, M, DE1, DEx1, DEy1, DE2, DEx2, DEy2, diffeqs, funcs, in itconds, sol, solx1, soly1, solx2, soly2, plot1, plot2, point1, point2 :\n r1 := t -> Vector([x1(t),y1(t)]):\n r2 := t -> Vector([x2(t),y2( t)]):\n r12 := t -> r2(t) - r1(t):\n M := v -> sqrt(DotProduct(v,v)) :\n DE1 := m1 * (map(diff,r1(t),t$2)) = simplify(c * m1 * m2/(M(r12(t ))^2) * (r12(t))/(M(r12(t)))):\n DEx1 := lhs(DE1)[1] = rhs(DE1)[1 ]:\n DEy1 := lhs(DE1)[2] = rhs(DE1)[2]:\n DE2 := m2*(map(diff,r2(t), t$2)) = simplify(c*m2*m1/(M(r12(t))^2)* (-r12(t))/(M(r12(t)))):\n DEx 2 := lhs(DE2)[1] = rhs(DE2)[1]:\n DEy2 := lhs(DE2)[2] = rhs(DE2)[2]: \n diffeqs := DEx1, DEy1, DEx2, DEy2:\n funcs := x1(t), y1(t), x2(t) , y2(t):\n initconds := x1(0)=X1, y1(0)=Y1, x2(0)=X2, y2(0)=Y2, D(x1) (0)=dX1, D(y1)(0)=dY1, D(x2)(0)=dX2, D(y2)(0)=dY2:\n sol := dsolve(\{ diffeqs,initconds\},\{funcs\},numeric):\n solx1 := s -> subs(sol(s),x 1(t)):\n soly1 := s -> subs(sol(s),y1(t)):\n solx2 := s -> subs(sol( s),x2(t)):\n soly2 := s -> subs(sol(s),y2(t)):\n setoptions(view=[ne gX..posX,negY..posY],scaling=constrained, axes=boxed):\n plot1 := plo t(['solx1(t)','soly1(t)',t=0..T],color=red):\n plot2 := plot(['solx2( t)','soly2(t)',t=0..T],color=blue):\n point1 := plot([[solx1(T),soly1 (T)]], style=point, symbol=diamond, symbolsize=10, color=red):\n poin t2 := plot([[solx2(T),soly2(T)]], style=point, symbol=diamond, symbols ize=10, color=blue):\n display([plot1,plot2,point1, point2]);\nend pr oc:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}{PARA 7 "" 1 "" {TEXT -1 50 "Warning, the name changecoords has been redefined\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "Display(gravityMaplet);" }}{PARA 6 "" 1 "" {TEXT -1 38 "Initializing Java runtime environment." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {MARK "0 1 0" 50 }{VIEWOPTS 1 1 0 3 4 1802 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }