Autor Beitrag
ace1905
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 73



BeitragVerfasst: Mo 10.12.07 18:50 
Moderiert von user profile iconChristian S.: Abgetrennt von [url=www.delphi-forum.de/...p?t=79001]hier[/url]

cool danke!
haste vielleicht noch jemand einen rat wie ichs am besten anstell, dass der graph nicht mehr so eckig ist?
wahrscheinlich einfach mehr stellen berechnen nehm ich an oder?
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mo 10.12.07 19:05 
ja

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
ace1905 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 73



BeitragVerfasst: Mo 10.12.07 19:25 
ich habs probiert aber immer wenn ichs genauer mach wird der graph immer dicker wegen den ganzen strichen die ich zieh...ich mach das mit moveto() und lineto(). deshalb überschreiden sich die linien und es wird son dicker strich auch wenn ich sagen muss dass es dadurch viel runder geworden ist.
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mo 10.12.07 19:38 
PSEUDO:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
X := Start;
MoveTo(X,f(X));
while x<Ende do
begin
  X := X+Step;
  LineTo(X,f(X));
end;

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
ace1905 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 73



BeitragVerfasst: Mo 10.12.07 22:22 
tut mir leid aber ich versteh nicht ganz was du damit meinst :?:
ich stell nochmal meinen quellcode rein weil ich mir denken kann dass es auch da verbesserungen gibt
für ein paar variablen mit evt. schlechter namensgebung möchte ich mich entschuldigen :-P
ace1905 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 73



BeitragVerfasst: Mo 10.12.07 22:25 
mist hat irgendwie nich geklappt :evil:
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:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, Buttons;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Edit_d: TEdit;
    Edit_p: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Button1: TButton;
    Button2: TButton;
    Label_x1: TLabel;
    Label_x2: TLabel;
    Edit_q: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Label5: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  koordinatenarray: array[0..50,1..4] of Integer;

implementation

{$R *.dfm}

procedure koordinaten (var p, q, d : real);
var i, co_y1, co_y2, y, z : Integer;
    ergebnis1, ergebnis2, x, y1, y2, w: real;
begin
w := -4.5;
x := -5;
y := 25;
z := 0;
for i:=0 to 50 do
begin
x := x+0.2;
w := w+0.2;

ergebnis1 := d*sqr(x)+ p*x + q;
ergebnis2 := d*sqr(w)+ p*w + q;

y1 := 5-ergebnis1;

y2 := 5-ergebnis2;


co_y1 := Trunc(y1*50);        //+++++++++Real in Integer umwandeln++++++
co_y2 := Trunc(y2*50);

z:= z+10;
y:= y+10;

koordinatenarray[i,1] := z;

koordinatenarray[i,2] := y;
koordinatenarray[i,3] := co_y1;
koordinatenarray[i,4] := co_y2;
end;
end;



procedure TForm1.FormCreate(Sender: TObject);
begin
  Image1.Canvas.MoveTo(0,250);
  image1.Canvas.LineTo(500,250);
  image1.Canvas.MoveTo(250,0);
  image1.Canvas.LineTo(250,500);
end;

procedure TForm1.Button1Click(Sender: TObject);
var p, q, a, b, c, d, x1, x2, round_x1, round_x2, x1stelle, x2stelle : real;
    x1pixel, x2pixel : Integer;

begin
p := StrToFloat(Edit_p.Text);
q := StrToFloat(Edit_q.Text);
d := StrToFloat(Edit_d.Text);

if d<> 1 Then
begin
p := p/d;
q := q/d;
end;
c := p*p;
a := (c/4) - q;
                                 //#####################################
if a < 0 then                   //++++++++++Keine Lösung+++++++++++++++
begin
Showmessage('Es gibt keine Lösung! Die Wurzel enthält eine negative Zahl');
Label_x1.Caption := 'x1: ';
Label_x2.Caption := 'x2: ';
end
else                            //#####################################
if a = 0 Then                  //+++++++++++Eine Lösung++++++++++++++++
begin
x1 := (-1*p/2);
Label_x1.Caption := 'x1:  '+FloatToStr(x1);
Label_x2.Caption := '';
round_x1 := round(x1*100)/100;      //+++++++++X-Wert runden++++++++++++++
if round_x1 < 0 Then
begin
x1stelle := 5+round_x1;
end
else
begin
x1stelle := 5+round_x1;
end;
x1pixel := Trunc(x1stelle*50);         //++++++++Real zu Integer umwandeln++++++
Image1.Canvas.MoveTo(x1pixel,254);     //++++++++Nullstelle markieren+++++++++++
Image1.Canvas.LineTo(x1pixel,246);

end
else                           //###########################################
if a > 0 Then                 //+++++++++++++Zwei Lösungen+++++++++++++++
begin
b := sqrt(a);
x1 := (-1*p/2) + b;
x2 := (-1*p/2) - b;
Label_x1.Caption := 'x1:  '+FloatToStr(x1);
Label_x2.Caption := 'x2:  '+FloatToStr(x2);
round_x1 := round(x1*100)/100;         //+++++++++X-Werte runden++++++++++++++
round_x2 := round(x2*100)/100;
if round_x1 < 0 Then
begin
x1stelle := 5+round_x1;
end
else
begin
x1stelle := 5+round_x1;
end;

if round_x2 < 0 Then
begin
x2stelle := 5+round_x2;
end
else
begin
x2stelle := 5+round_x2;
end;

x1pixel := Trunc(x1stelle*50);        //+++++++++Real in Integer umwandeln++++++
x2pixel := Trunc(x2stelle*50);

Image1.Canvas.MoveTo(x1pixel,254);    //+++++++++Nullstellen markieren+++++++++
Image1.Canvas.LineTo(x1pixel,246);

Image1.Canvas.MoveTo(x2pixel,254);
Image1.Canvas.LineTo(x2pixel,246);

end;

end;


procedure TForm1.Button2Click(Sender: TObject);
var p, q, d : real;
    i, z, y, y1pixel, y2pixel : Integer;
begin
p := StrToFloat(Edit_p.Text);
q := StrToFloat(Edit_q.Text);
d := StrToFloat(Edit_d.Text);
koordinaten(p,q,d);
for i := 0 to 50 do
begin
z:=koordinatenarray[i,1];
y:=koordinatenarray[i,2];
y1pixel:=koordinatenarray[i,3];
y2pixel:=koordinatenarray[i,4];

Image1.Canvas.MoveTo(z ,y1pixel);    //+++++++++Linie ziehen+++++++++

Image1.Canvas.LineTo(y ,y2pixel);
end;

end;


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

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
  Image1.Picture := nil;
  Image1.Canvas.MoveTo(0,250);
  image1.Canvas.LineTo(500,250);
  image1.Canvas.MoveTo(250,0);
  image1.Canvas.LineTo(250,500);
  Label_x1.Caption := 'x1: ';
  Label_x2.Caption := 'x2: ';
  Edit_p.Clear;
  Edit_q.Clear;
  Edit_d.Clear;
end;

end.