Add(MainForm,2953706,21,105) { Width=553 Height=547 } Add(PaintBox,6464998,189,161) { Width=545 Height=520 Align=5 Color=16777215 } Add(MMTimer,3013379,77,161) { Interval=10 link(onTimer,1688360:doDraw,[]) } Add(InlineCode,1688360,140,161) { WorkPoints=#6:doDraw| EventPoints=#6:onDraw| DataPoints=#5:CDraw| Code=#15:unit HiAsmUnit;|0:|9:interface|0:|21:uses kol,Share,Debug;|0:|4:type|17: TVector = record|14: x,y:double;|5: end;|1: |15: TBody = record|12: m:double;|14: x,y:double;|13: v:TVector;|5: end;|0:|28: THiAsmClass = class(TDebug)|10: private|14: p1:TBody;|14: t1:TBody;|9: public|28: CDraw,onDraw:THI_Event;|5: |24: constructor Create;|51: procedure doDraw(var _Data:TData; Index:word);|5: end;|0:|14:implementation|0:|37:procedure _debug(r:double); overload;|5:begin|24: _debug(double2str(r));|4:end;|0:|31:constructor THiAsmClass.Create;|5:begin|15: p1.m := 4E12;|14: p1.x := 200;|14: p1.y := 200;|14: p1.v.x := 0;|14: p1.v.y := 0;|2: |12: t1.m := 1;|14: t1.x := 400;|14: t1.y := 400;|14: t1.v.x := 1;|16: t1.v.y := 1.5;|4:end;|0:|29:procedure THiAsmClass.doDraw;|14:const t = 0.1;|16:var bmp:PBitmap;|14: a:TVector;|15: v,r:double;|15: s,c:double;|5:begin|33: bmp := ReadBitmap(_Data,CDraw);|25: Bmp.BkColor := clWhite;|41: Bmp.Canvas.Brush.BrushStyle := bsSolid;|38: Bmp.Canvas.FillRect(Bmp.BoundsRect);|2: |65: r := (t1.x - p1.x)*(t1.x - p1.x) + (t1.y - p1.y)*(t1.y - p1.y);|14:// _debug(r);|27: v := 6.67E-11 * p1.m / r;|32: c := -(t1.x - p1.x) / sqrt(r);|32: s := -(t1.y - p1.y) / sqrt(r);|15: a.x := c * v;|15: a.y := s * v;|14:// _debug(c);|14:// _debug(s);|46: t1.x := t1.x + t1.v.x * t{ + a.x * t*t / 2};|46: t1.y := t1.y + t1.v.y * t{ + a.y * t*t / 2};|25: t1.v.x := t1.v.x + a.x;|25: t1.v.y := t1.v.y + a.y;|2: |27: with bmp.Canvas^ do begin|28: pen.PenStyle := psSolid;|25: pen.Color := clBlack;|22: pen.PenWidth := 2;|32: brush.brushStyle := bsSolid;|27: brush.color := clBlack;|36: MoveTo(round(p1.x),round(p1.y));|40: LineTo(round(p1.x+2),round(p1.y+2));|36: MoveTo(round(t1.x),round(t1.y));|40: LineTo(round(t1.x+1),round(t1.y+1));|6: end;|22: _hi_onEvent(onDraw);|4:end;|0:|4:end.| link(onDraw,6464998:doRefresh,[]) link(CDraw,6464998:Bitmap,[(146,149)(170,149)(170,205)(195,205)]) }