Autor Beitrag
Dr. Phil
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 66

Win XP
Delphi 7 Prof.
BeitragVerfasst: Di 27.07.04 20:20 
Hallo,
ich hab mir hier schon ne Menge Beiträge zu dem Thema durchgelesen, aber bei mir funktioniert das einfach nicht richtig.
Bei mir kommen Y-Positionen ála -20000539 raus. Gut, so wird das natürlich nicht richtig angezeigt ;)
ausblenden Delphi-Quelltext
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:
procedure TForm1.Button1Click(Sender: TObject);
var
  t, x, y, x0, y0: integer;
  g, vx_0, vy_0, a, v: Real;
begin
  With image1.Canvas do begin
    Pen.color:=clblack;
    brush.color:=clgreen;
    pen.mode:=pmCopy;
    MoveTo(0,0);
    ListBox1.Clear;
    ListBox2.Clear;
    refresh;
    x0 := StrToInt(txtX.Text);
    y0 := StrToInt(txtY.Text);
    vx_0 := StrToFloat(txtA.Text);
    vy_0 := StrToFloat(txtV.Text);
    g := StrToFloat(txtG.Text);
    MoveTo(x0,y0);
    For t := 0 to 640 do begin
      x := round(vx_0) * t + x0;
      y := round(vy_0) * t + round((-1/2)*g)*(t*t) + y0;
      Listbox1.Items.Add(IntToStr(x));
      Listbox2.Items.add(IntToStr(y));
      LineTo(x,y);
    end;
  end;
end;

ja, das ist jetzt kein wirklich schöner Code, war ja nur ne Demo.
Ich zeichne hier auf ein TImage.

_________________
self-improvement is masturbation;
self-destruction is the answer - Tyler Durden
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Di 27.07.04 20:42 
Tja, wenn oben 0 ist und es nach unten in Richtung oo geht, dann solltest du nicht -1/2*g nehmen, oder der Ball fliegt nach oben ;-)
Dann werden zumindest die Werte positiv, um die richtigen Verhältnisse musst du dich selber kümmern, entweder legst du fest, wieviele Pixel ein MEter sein sollen, oder du wählst entsprechend kleine Werte für v und g.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
Dr. Phil Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 66

Win XP
Delphi 7 Prof.
BeitragVerfasst: Di 27.07.04 21:45 
Naja und was soll ich anstellen wenn ich z.B. aus 100 Pixeln einen Meter machen will?

_________________
self-improvement is masturbation;
self-destruction is the answer - Tyler Durden
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Di 27.07.04 22:10 
Alle Eingaben mit 100 multiplizieren. Gibt man dann 1 für die Position ein, kommt man bei 100 wieder raus, und da malst du deinen Punkt auf den canvas ;-)

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
umpani
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 389



BeitragVerfasst: Mi 28.07.04 07:44 
Hallo,

gab es hier schonmal (incl Quelltext)


www.delphi-forum.de/viewtopic.php?t=12456

Gruß Umpani

_________________
Lernen, ohne zu denken, ist eitel; denken, ohne zu lernen, ist gefährlich. Konfuzius
Dr. Phil Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 66

Win XP
Delphi 7 Prof.
BeitragVerfasst: Mi 28.07.04 08:12 
Ja ich weiß Umpani, ich war bis jetzt nur zu faul dein Projekt runterzuladen :roll:
Ich schaus mir mal an wenn ich zuhause bin, es ist jetzt sowieso nur mehr bisserl Umrechnung.

_________________
self-improvement is masturbation;
self-destruction is the answer - Tyler Durden