Einzelnen Beitrag anzeigen

Maximus

Registriert seit: 26. Okt 2003
169 Beiträge
 
#3

Re: Überlauf bei Fließkommoperation

  Alt 12. Apr 2005, 15:56
Hier mal die Berechnungs Procedure. Die Variablen sind alle bis auf die "Vorzeichen-Variablen" als Extended deklariert

Delphi-Quellcode:
procedure TBallEngine.Move;
var aw, ax, ay, lookX, lookY: Extended;
    vor_vx, vor_vy: Integer;
begin
 lookX := x + vx * tau;
 lookY := y + vy * tau;

 if (lookX > 700-Breite) or (lookX < 0) then vx := -e * vx;
 if (lookY > 300) or (lookY < Hoehe) then vy := -e * vy;

 if x < 0 then x := 0;
 if x > 700-Breite then x := 700-Breite;
 if y < Hoehe then y := Hoehe;
 if y > 300 then y := 300;

 aw := k * vw * vw;
 ax := k * vx * vx; //nach einem Fehler springt er immer in eine dieser 3 Zeilen
 ay := k * vy * vy;

 if vx < 0 then vor_vx := 1 else vor_vx := -1;
 if vy < 0 then vor_vy := 1 else vor_vy := -1;

 vx := vx + vorz_vw * aw * tau + vor_vx * ax * tau;
 vy := vy - g * tau + vor_vy * ay * tau;

 x := x + vx * tau;
 y := y + vy * tau;
end;
MFG
Maximus
  Mit Zitat antworten Zitat