1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300:
| unit ukepler;
{$IFDEF FPC} {$MODE Delphi} {$ENDIF}
interface
uses {$IFnDEF FPC} Windows, {$ELSE} LCLIntf, LCLType, LMessages, {$ENDIF} Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, Spin;
type
TLargeInteger = Int64;
TForm1 = class(TForm) Panel1: TPanel; Button1: TButton; PaintBox1: TPaintBox; SpinEdit1: TSpinEdit; SpinEdit2: TSpinEdit; RadioButton1: TRadioButton; RadioButton2: TRadioButton; RadioButton3: TRadioButton; SpinEdit3: TSpinEdit; Timer1: TTimer; Label1: TLabel; Label2: TLabel; Label3: TLabel; procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); procedure FormResize(Sender: TObject); procedure Paintbox1P(Sender: TObject); procedure FormShow(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure SpinEdit1Change(Sender: TObject); private bmp1Planet, bmp,bmp2Planets : tBitmap; kep1,kep2,mx,my:integer; ob,ob2:array[0..460] of tpoint; epsilon,epsilon2 : double; a,b,e,a2,e2,b2, wkepler, wi,wkepler2:double; procedure myBitmapInit(Sender: TObject); public end;
var Form1: TForm1;
implementation
{$IFnDEF FPC} {$R *.dfm} {$ELSE} {$R *.lfm} {$ENDIF}
function keplerg(m,e:double):double; var ea,eo:double; begin ea:=m; eo:=0; while abs(eo-ea)>0.007 do begin eo:=ea; ea:=m+e*sin(ea); end; result:=ea; end;
procedure TForm1.myBitmapInit(Sender: TObject); const k = 'Sonne'; var can: tCanvas; begin IF bmp1Planet<> NIL then freeAndNil(bmp1Planet); bmp1Planet:=tbitmap.create; bmp1Planet.width:=paintbox1.width; bmp1Planet.Height:=paintbox1.Height;
can:=bmp1Planet.canvas; can.Brush.Style:= bsSolid; can.Brush.Color:= clwindow; can.Rectangle(can.ClipRect); can.Font.name:='Verdana';
epsilon:=spinedit1.value/100; a:=(bmp1Planet.width-150)/2; e:=a*epsilon; b:=sqrt(a*a-e*e); if b>(bmp1Planet.height-80)/2 then begin b:=(bmp1Planet.height-80)/2; a:=sqrt(b*b/(1-epsilon*epsilon)); e:=a*epsilon; end;
epsilon2:=spinedit2.value/100; a2:=a*0.629961; e2:=a2*epsilon2; b2:=sqrt(a2*a2-e2*e2);
mx:=bmp1Planet.width div 2; my:=bmp1Planet.height div 2; can.pen.color:=clgreen; can.moveto(round(mx-a-10),my); can.lineto(round(mx+a+10),my); can.moveto(mx,round(my-b-10)); can.lineto(mx,round(my+b+10));
can.brush.style:=bsSolid; can.pen.color:=clyellow; can.brush.color:=clyellow; can.ellipse(round(mx-e-10),my-10,round(mx-e+11),my+11); can.brush.style:=bsclear; can.font.color:=clBlack; can.textout(round(mx-e-can.textwidth(k) div 2),my+10,k); can.pen.color:=clblue; can.ellipse(round(mx-a),round(my-b),round(mx+a+1),round(my+b+1)); bmp.Assign(bmp1Planet);
bmp2Planets.Assign(bmp1Planet); can:=bmp2Planets.canvas; can.Brush.Style:= bsClear; can.pen.color := clfuchsia; bmp2Planets.canvas.ellipse(round(mx-e+e2-a2),round(my-b2),round(mx-e+e2+a2+1),round(my+b2+1)); end;
procedure TForm1.Paintbox1P(Sender: TObject); var i,xp,yp,xp2,yp2:integer; punkte:array[0..460] of tpoint; k:string; can:tcanvas; begin if radiobutton3.checked then bmp.Canvas.draw(0,0,bmp2Planets) else bmp.Canvas.draw(0,0,bmp1Planet);
can := bmp.Canvas;
xp2:=0; yp2:=0;
if radiobutton2.checked then begin can.pen.color:=clgray; if kep1>0 then begin can.brush.style:=bsbdiagonal; can.brush.color:=clyellow; for i:=0 to kep1-1 do begin punkte[i].x:=ob[i].x; punkte[i].y:=ob[i].y; end; punkte[kep1].x:=round(mx-e); punkte[kep1].y:=my; can.polygon(slice(punkte,kep1+1)); end; if kep2>0 then begin can.brush.style:=bsbdiagonal; can.brush.color:=cllime; for i:=0 to kep2-1 do begin punkte[i].x:=ob2[i].x; punkte[i].y:=ob2[i].y; end; punkte[kep2].x:=round(mx-e); punkte[kep2].y:=my; can.polygon(slice(punkte,kep2+1)); end;
if (spinedit3.value>0) and (spinedit3.value<20) then begin kep1:=0; kep2:=0; end; end;
wi:=spinedit3.value*pi/180; wkepler:=keplerg(wi,epsilon); xp:=round(mx-a*cos(wkepler)); yp:=round(my-b*sin(wkepler));
can.brush.Style:=bsClear; can.pen.color:=clfuchsia; can.moveto(round(mx-e),my); can.lineto(xp,yp);
can.pen.color:=clblack; can.brush.color:=clred; can.brush.style:=bssolid; can.ellipse(xp-5,yp-5,xp+6,yp+6);
if radiobutton3.checked then begin wi:=2*spinedit3.value*pi/180+pi/4; wkepler2:=keplerg(wi,epsilon2); xp2:=round(mx-e+e2-a2*cos(wkepler2)); yp2:=round(my-b2*sin(wkepler2)); can.brush.color:=clnavy; can.ellipse(xp2-5,yp2-5,xp2+6,yp2+6); end;
if radiobutton2.checked then begin if (spinedit3.value <=5) then kep1:=0 else if (spinedit3.value <=90) then Begin ob[kep1].x:=xp; ob[kep1].y:=yp; inc(kep1); end; if spinedit3.value <=round(100+20*(1+epsilon)) then kep2:=0 else if kep2<kep1 then begin ob2[kep2].x:=xp; ob2[kep2].y:=yp; inc(kep2); end; end;
k:='Planet'; can.brush.Style:=bsClear; can.textout(xp-can.textwidth(k) div 2,yp+9,k); if radiobutton3.checked then can.textout(xp2-can.textwidth(k) div 2,yp2+9,k);
paintbox1.Canvas.draw(0,0,bmp); end;
procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction); begin bmp1Planet.Free; bmp.free; bmp2Planets.free; end;
procedure TForm1.FormResize(Sender: TObject); begin FormShow(sender); end;
procedure TForm1.FormShow(Sender: TObject); begin kep1:=0; kep2:=0; bmp:= TBitmap.create; bmp2Planets:= TBitmap.create; myBitmapInit(Sender); bmp.Assign(bmp1Planet); end;
procedure TForm1.Button1Click(Sender: TObject); begin timer1.Enabled:=not timer1.Enabled; end;
procedure TForm1.Timer1Timer(Sender: TObject); var x:integer; begin x:=spinedit3.value+1; if x>spinedit3.MaxValue then x:=spinedit3.minvalue; spinedit3.Value:=x; end;
procedure TForm1.SpinEdit1Change(Sender: TObject); begin kep1:=0; kep2:=0; epsilon:=spinedit1.value/100; myBitmapInit(Sender); paintbox1p(sender); end;
end. |