Autor Beitrag
Infoteacher
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Di 08.03.05 18:51 
Hallo :cry:
Also ich soll zwei lineare Funktionen (also y=m*x+n) in einem Koordinatensystem darstellen. Der Benutzer kann die Funktion durch Edit Fenster ändern.
Ich weiß bloß nicht wie das alles geht.
Und von den beiden Funktionen werden dann noch die Nullstellen berechnet.
Kroni
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: Di 08.03.05 18:57 
Also....du solltest vlt. mit Canvas arbeiten, das könnte das ganze noch verkraften.
DAnn musst du ja uach ein Intervall festlegen, in welchem du den Graph anzeigen lassen möchest.
Dann kannste di rmit TCanvas n Koordianten system bauen, dir zwei Punkte der Geraden berechen, und diese dann mit dem Befehl Line umrechen,
Dafür musst du aber die Pixel in "Punkte", die du benutzt, umwandeln.
Und für nullstellenberechen:
Nullstelle: f(x)=0
<=> mx+n=0
<=> mx=-n
<=> x=-n/m
wobei m<>0 ! dann haste schonmal die x Koordinate, die y bekommste dann raus, indem du x einsetzt....;-)
ps hab mich hoffenltic nich verrechnet, habs nit aufm zettel gemacht^^
Infoteacher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Di 08.03.05 19:02 
Ja Nullstellen hab ich kapiert und Canvas is klar.
Ich stell die Funktion in einem Koordinatensystem von -10<x<10 und -10<y<10 dar.
Mein Canvas ist 400*400 groß!
Kroni
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: Di 08.03.05 19:06 
Weist du schon, wie du die Koordinaten umrechen musst??
Infoteacher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Di 08.03.05 19:34 
Also die x-Werte in Pixeln sind von 0 bis 400.
Und der Zahlenbereich der Funktion xf ist jetzt meinetwegen von -5 bis 5.
Dann rechne ich xf aus und dann noch yf!
Richtig??
Kroni
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: Di 08.03.05 19:37 
ja...nur du musst dann ja berehen, wie viel pixel eine Einheit sind.....also bruachst du nen faktor...oder auch zoomfaktor wie auchimmer...
und den mmusst du dann eben, wenn du meinetwegen deine 400 Pixel an breite hast, und du hast x werte von -5 bis +5, dann hast du insgesamt ne Breite von 10 Einheiten=> jede Einheit hat also 40 Pixel
und dann musste das entsprchenden in Pixel umrechen.
Da gibts aber auch schon ferrige Funktionen hier im Forum für, aber mach dir mal weiter GEdanken dazu1
Infoteacher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Di 08.03.05 19:43 
also kann ich dann schreiben:

(Eingabe a,b,c)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
for x:= 0 to 400 do begin
      xf:=x/40-5
      yf:=a*xf*xf+b*xf+c;
      y:=round(-40*yf+200);
     Paintbox1.Canvas.pixels[x,y]:=clred;
  end;


Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
Kroni
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: Di 08.03.05 19:47 
wenn du mir sagst, was du mit a, b, c und xf und yf und so meinst...dann kann ich dazu stellung nehmen^^
ansonsten wrüde ich dir raten, das umrechenn von Koordianten auf pixeln variabel zu machen
Infoteacher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Di 08.03.05 19:53 
Oh Gott mein Kopf! Der platzt gleich vor so vielen Variablen.
Also gut, variabel machen.

Kann ich aber nich einfach schreiben:
x:=strtofloat(edit1.text);
...
with paintbox1.canvas do begin
...
hier dann y=m*x+n
Kroni
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: Di 08.03.05 19:58 
jo, und dann musste ja, je nachdem wie weit deine X und Y Achse reicht, den Faktor berechenn.
Wobei wenn du das Intervall für die X Werte festgelegt hast, du noch die Y Achse variabel machen solltest, damit du auch die gesamte Gerade auf deine Form bekommst....;-)
Infoteacher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Di 08.03.05 20:00 
BOOOOOOOOM!!!!!!!!!!
mein Kopf is geplatzt
Infoteacher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Di 08.03.05 20:17 
Kann mir nicht einer das Programm schreiben, dass ich was versteh???! :twisted:
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Di 08.03.05 20:20 
user profile iconInfoteacher hat folgendes geschrieben:
Kann mir nicht einer das Programm schreiben, dass ich was versteh???! :twisted:


Was für ein Paradoxer Satz :lol:
Damit du was lernst sollst du das selber schreiben.
Hier wird keiner deine Hausaufgaben machen.


Zuletzt bearbeitet von Karlson am Di 08.03.05 20:22, insgesamt 1-mal bearbeitet
OneOfTen
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 08.03.05 20:21 
user profile iconInfoteacher hat folgendes geschrieben:
BOOOOOOOOM!!!!!!!!!!
mein Kopf is geplatzt


also bitte, stell dich mal nicht so ungeschickt an :wink: so schwer ists nun wirklich nich oder? :wink:
Infoteacher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Di 08.03.05 20:32 
Oh ich bin kopflos!
Also sind keine Hausaufgaben!
Ich versuchs dann mal weiter ihr ...

edit: is mir wirklich zu schwer
Infoteacher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Di 05.04.05 19:03 
So ich hab das Programm fast fertig.
Stell gleich mal nen Teil des Quelltextes rein der mir Kopfzerbrechen bereitet hat.
Infoteacher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Di 05.04.05 19:07 
Schnittwinkel ist nicht ganz richtig (noch!!)

ausblenden volle Höhe 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:
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:
procedure TForm1.Button1Click(Sender: TObject);
    var xf,yf,m1,n1,m2,n2:real;
    var x,y:integer;
begin
    m1:=strtofloat(edit1.text);   {1.Funktion}
    n1:=strtofloat(edit2.text);
     for x:= 0 to 400 do begin
        xf:=x/25-8;
        yf:=m1*xf+n1;             {y=m*x+n}
        y:=round(-25*yf+200);
        Paintbox1.canvas.pixels[x,y]:=clblack;
    for y:=1 to 10000 do;
    end;
     m2:=strtofloat(edit3.text);   {2.Funktion}
     n2:=strtofloat(edit4.text);
       for x:= 0 to 400 do begin
        xf:=x/25-8;
        yf:=m2*xf+n2;              {y=m*x+n}
        y:=round(-25*yf+200);
        Paintbox1.canvas.pixels[x,y]:=clred;
    for y:=1 to 10000 do;
    end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   refresh;                   {Löscht Funktionen}
end;

procedure TForm1.Button3Click(Sender: TObject);
    var m1,n1,m2,n2:real;
    var x1,x2:real;
begin
    m1:=strtofloat(edit1.text);         {Nullstellen}
    n1:=strtofloat(edit2.text);
    m2:=strtofloat(edit3.text);
    n2:=strtofloat(edit4.text);

    if (m1=0or (n1=0then showmessage ('keine Lösung Funktion 1')
                        else
                            begin x1:=-(n1/m1);                   {Bedingung 1}
                                   label12.caption:=floattostr(x1);
                            end;

     if (m2=0or (n2=0then showmessage ('keine Lösung Funktion 2')
                        else
                            begin x2:=-(n2/m2);                  {Bedingung 2}
                                   label11.caption:=floattostr(x2);
                            end;
   
end;

procedure TForm1.Button4Click(Sender: TObject);
    var m1,n1,m2,n2:real;
    var sp,y:real;
begin
    m1:=strtofloat(edit1.text);         {Schnittpunkt}
    n1:=strtofloat(edit2.text);
    m2:=strtofloat(edit3.text);
    n2:=strtofloat(edit4.text);

    sp:=(n2-n1)/(m1-m2);                  {s(x)}
    y:=m1*sp+n1;                          {s(y)}

    Label15.caption:=FloatToStr(sp);      {Ausgabe x}
    Label17.caption:=FloatToStr(y);       {Ausgabe y}
end;

procedure TForm1.Button5Click(Sender: TObject);
    var m1,m2:real;
    var w1,w2,wges:real;
begin
    m1:=strtofloat(edit1.text);         {Schnittwinkel}
    m2:=strtofloat(edit3.text);

    w1:=(m2-m1);
    w2:=arctan(w1);
    wges:=(180*w2)/pi;

    Label20.Caption:=FloatToStr(wges);
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
    close;
end;

end.


Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 05.04.05 19:19 
@Infoteacher: Könntest Du bitte Delphi-Tags für deinen Quelltext verwenden? Dafür gibt's die Teile ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.