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:
| unit PVektor;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DXDraws, ComCtrls, DXClass, DXSounds, StdCtrls, DXSprite, DXInput, ExtCtrls, Math;
type TPVektor = class private Be, Wink: Real; public procedure Draw(Canvas: TDirectDrawSurfaceCanvas; x,y : Integer; Color : TColor); procedure AddVector(Vektor: TPVektor); property Betrag : Real read Be write Be; property Winkel : Real read Wink write Wink; end;
implementation uses Manvoever;
procedure TPVektor.Draw(Canvas: TDirectDrawSurfaceCanvas; x,y : Integer; Color : TColor); var xVek, yVek: integer; begin Canvas:=Canvas.Create(Form1.DXD_Main.Surface); XVek:=Floor(Be*cos(Wink)); YVek:=Floor(Be*sin(Wink)); With Canvas do begin Pen.Color := Color; Pen.Width := 2; MoveTo(x,y); LineTo(x+XVek,y+YVek); end; Canvas.Free; end;
procedure TPVektor.AddVector(Vektor: TPVektor); var x1, y1, x2, y2, x3, y3: Real; begin if Be<0 then begin Be:=-Be; Wink:=Wink+2*Pi; end; if Vektor.Betrag<0 then begin Vektor.Betrag:=-Vektor.Betrag; Vektor.Winkel:=Vektor.Winkel+2*Pi; end; x1:= Be*cos(Wink); y1:= Be*sin(Wink); x2:= Vektor.Betrag*cos(Vektor.Winkel); y2:= Vektor.Betrag*sin(Vektor.Winkel); x3:= x1+x2; y3:= y1+y2; Betrag:=sqrt(sqr(x3)+sqr(y3)); Winkel:= ArcCosh(x3/Betrag); end;
end. |