'This program draws a binary system of an electron and 'proton in an elliptical orbit. We follow the laws 'of Kepler. They sweep out equal areas in equal times. 'Each position of the electron and proton are separated 'by equal areas and time periods. nomainwin WindowWidth = 900 WindowHeight = 800 open "ellipse.txt"for graphics as #1 #1 "color black ; down ; size 1 " ' #1 "rule "; _R2_NOTXORPEN for zzz=1 to 10:gosub [main] if zzz<10 then #1 "cls ":gosub [delay] next zzz goto [exit] '********************************************* [delay] for z=0 to 3000:next z '#1 "cls " return '********************************************* [main] fr = .4'eccentricity x0=600'right focus y0=360 pi = asn(1) * 2 circleR= 750'200 'width of ellipse a=circleR/2 'a=half width of ellipse outer = circleR/2*(1-fr) '=140 focus to right side of ellipse eccx = fr eccy = sqr(1 - eccx^2) b=a*eccy areaellipse=pi*a*b dfoci = circleR*fr/2' =60 half distance between foci divider=31:dec=6.28*.1/divider area=areaellipse/divider '11 using constant area triangles '************************************************** r = outer+.05 angle =0 #1 "color blue ":#1 "backcolor blue" #1 "place "; x0 ; " "; y0 #1 "goto "; x0 - outer/5 ; " "; y0 'top circle #1 "circlefilled 2 " #1 "color red ":#1 "backcolor red" #1 "place "; x0 ; " "; y0 #1 "goto "; x0 + outer ; " "; y0 'top circle #1 "circlefilled 8 " gosub [delay] while angle< 3.14159 - dec #1 "color red ":#1 "backcolor red" gosub [doCosAngle] #1 "place "; x0 ; " "; y0 #1 "goto "; x0 + (r*cosAngle) ; " "; y0 + (r*sinAngle)'top circle #1 "circlefilled 8 " #1 "color blue ":#1 "backcolor blue" #1 "place "; x0 ; " "; y0 #1 "goto "; x0 + -1*(r/5*cosAngle) ; " "; y0 + -1*(r/5*sinAngle) ; #1 "circlefilled 2 " gosub [delay] wend while angle < 6.28 - (20*dec) gosub [doCosAngle] #1 "color red ":#1 "backcolor red" #1 "place "; x0; " "; y0 #1 "goto "; x0+r*cosAngle ; " "; y0+ (-1*r*sinAngle) ;'bottom circle #1 "circlefilled 8 " #1 "color blue ":#1 "backcolor blue" #1 "place "; x0 ; " "; y0 #1 "goto "; x0 + -1*(r/5*cosAngle) ; " "; y0 + (r/5*sinAngle) ; #1 "circlefilled 2 " gosub [delay] wend return '************************************************** [doCosAngle] 'angle = ACS(((circleR/2*(1 - fr^2)/r) - 1)/fr)'r sets the angle anginc=area/r^2 r1 =circleR/2*(1 - fr^2)/(cos(angle+anginc)*fr+1) anginc=area/(r*r1) r1 =circleR/2*(1 - fr^2)/(cos(angle+anginc)*fr+1) angle=angle+anginc cosAngle =cos(angle)'((circleR/2*(1 - fr^2)/r1) - 1)/fr sinAngle = sin(ACS(cosAngle)) 'why does this work r = r1 return '************************************************** [exit] #1 "flush " 'gosub [save] wait ' #1 "discard"'no redraw info kept close #1 end '************************************************** [save] #1 "getbmp drawing 1 1 "; 800;" ";800 ' #1 "place 1 1 "; ' #1 "box "; 286; " "; 284; ' #1 "flush" filedialog "Save as...", "test", filename$ if filename$ = " " then wait filename$ = filename$ + ".bmp" bmpsave "drawing", filename$ return '**************************************************