Autor Beitrag
Dodekaeder
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

WinXP,Win95
Delphi 5
BeitragVerfasst: Mi 29.03.06 16:37 
Hallo, allerseits!

Ich hab ein kleines Programm zum schrägen Wurf geschrieben, und es finktioniert eigentlich aus alles, nur glaube ich werden die Kurven falsch dargestellt.

Also ich habe 6 Edit felder zur Daten eingabe + checkbox5 + RadioGroup2

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:
procedure TForm1.Button8Click(Sender: TObject);//schräger wurf zeichnen
var
zoom,b,c:integer; //b=x und c=y
combobox5:boolean;
y,x,sw,sh,th,a,v,vt,h,tw,r,s:real;
begin

try
try

v:=strtofloat(edit20.text);
h:=strtofloat(edit41.text);
a:=strtofloat(edit21.text);   //alpha
zoom:=strtoint(edit22.text);
b:=strtoint(edit25.text);     //x ändern
c:=strtoint(edit26.text);  //y ändern

if RadioGroup2.Itemindex=0 then // cw ist der Luftwiderstandswert(ist aber nur  selbst ausgedacht, also nicht wundern) 
begin
cw:=1.05;
end;
if RadioGroup2.Itemindex=1 then
begin
cw:=1.06
end;
if RadioGroup2.Itemindex=2 then
begin
cw:=1.08
end;
if RadioGroup2.Itemindex=3 then
begin
cw:=1.1
end;
if RadioGroup2.Itemindex=4 then
begin
cw:=1.15
end;
if RadioGroup2.Itemindex=5 then
begin
cw:=1.2
end;

if v=0 then
begin
showmessage('v0 muss größer als 0 sein!');
end;
if a=0 then
begin
showmessage('Alpha muss größer als 0 sein!');
end;
if a>90 then
begin
showmessage('Alpha muss kleiner als 90 sein!');
end;

th:=(v*sin(a))/9.81;
sw:=((sqr(v)*sin(2*a))/9.81)+h;

if tan(a)<0 then
begin
if cos(a)<0 then
begin
showmessage('Da tan(alpha) und oder cos(alpha) negativ sind,'#10#13'ist die Bahnkurve im 2. Quadranten!');
end;
end;

x :=-1000;
Repeat
y :=-c; //x achse
image3.Canvas.Pixels [round(x),round(-y)]:= clblack;
x := x + 0.01; //Abstand der Punkte
Until x >1000;

y :=-1000;
Repeat
x :=b; //y achse
image3.Canvas.Pixels [round(x),round(-y)]:= clblack;
y:= y + 0.01; //Abstand der Punkte
Until y>1000;

{r:=tan(a)*h-(9.81/(2*sqr(v)*sqr(cos(a)))*sqr(h));
label83.caption:=floattostr(r);

s:=tan(a)-(((9.81)/(2*sqr(v)*sqr(cos(a))))*2*h);
label84.caption:=floattostr(s);

x :=-1000;
Repeat
y :=(s*x)-(s*c);//anstiegsgerade // das hier ist nur testweise für den Anstieg in punkt x=h
image3.Canvas.Pixels [round(x),round(-y)]:= clred;
x := x + 0.01; //Abstand der Punkte
Until x >1000; }


if checkbox2.checked=false then
begin

x :=-1000;
Repeat

{f tan(a)>0 then
begin
if cos(a)>0 then     //rechts
begin}

y :=((tan(a)*x)-(9.81/(2*(sqr(v))*(sqr(cos(a))))*sqr(x))+h);  //schräger Wurf
image3.Canvas.Pixels [round(b+(x*zoom)),round(c+(-y*zoom))]:= clblue;
{end;
end;}


if tan(a)<0 then
begin
if cos(a)<0 then    //links
begin
y :=((tan(a)*x-(9.81/(2*sqr(v)*sqr(cos(a)))*sqr(x))+h));  //schräger Wurf
image3.Canvas.Pixels [round(b+(x*zoom)),round(c+(-y*zoom))]:= clblue;
end;
end;

x := x + 0.01; //Abstand der Punkte
Until x > 1000;

x :=-1000;
Repeat
y :=-c+((h+((sqr(tan(a)))/(4*(9.81/(2*sqr(v)*sqr(cos(a)))))))*Zoom); //Wurfhöhe  (parallel zu x achse)
image3.Canvas.Pixels [round(x),round(-y)]:= clsilver;
x := x + 0.01; //Abstand der Punkte
Until x >1000;

y :=-1000;
Repeat
x:=b+(((tan(a))/(2*((9.81)/(2*sqr(v)*sqr(cos(a))))))*Zoom); //wurfweite bei max höhe (parallel zu y achse)
image3.Canvas.Pixels [round(x),round(-y)]:= clsilver;
y:= y + 0.01; //Abstand der Punkte
Until y>1000;

y :=-1000;
Repeat
x:=b+(sw*Zoom);//wurfweite (parallel zu y achse)
image3.Canvas.Pixels [round(x),round(-y)]:= clsilver;
y:= y + 0.01; //Abstand der Punkte
Until y>1000;
end;

if checkbox1.checked=true then   //Sound nicht abspielen
begin
flag:=SND_ASYNC;
sndPlaySound(nil,flag)
end

else                            //Sound abspielen
begin
flag:=SND_ASYNC;
sndPlaySound(PChar('explode.wav'),flag);
end;

sh:=((sqr(v)*sqr(sin(a)))/(2*9.81))+h;
th:=(v*sin(a))/9.81;
tw:=2*th;
vt:=(v-9.81)*3.6;

label15.caption:=floattostrf(sw,fffixed,6,3);
label16.caption:=floattostrf(sh,fffixed,6,3);
label17.caption:=floattostrf(th,fffixed,6,3);
label18.caption:=floattostrf(tw,fffixed,6,3);
label43.caption:=floattostrf(vt,fffixed,6,3);


if checkbox2.checked=true then
begin
x:=-1000;
Repeat    //Lurfwiederstandskurve
y:=tan(a)*x-(9.81/(2*sqr(v)*sqr(cos(a)))*sqr(cw*x))+h;
image3.Canvas.Pixels [round(b+(x*zoom)),round(c+(-y*zoom))]:= clred;
x := x + 0.01; //Abstand der Punkte
Until x > 1000;
end;

if checkbox1.checked=true then   //Sound nicht abspielen
begin
flag:=SND_ASYNC;
sndPlaySound(nil,flag)
end

else                            //Sound abspielen
begin
flag:=SND_ASYNC;
sndPlaySound(PChar('explode.wav'),flag);
end;

except on E: econverterror do showmessage('Werte eingeben!');
end;
except on E:ezerodivide do showmessage ('Division durch 0 ist nicht definiert!');
end;
end;


So und mein Problem: bei alpha=45° wird eine normale(für45°) nach unten geöffnete Parabel 2ten grades angezeigt. Aber wenn Alpha z.B. 11 ist, ist der Anstieg viel zu goß als es eigentlich sein könnte...(11 ist nur ein beispielwert, auch bei einigen anderen Wabschusswinkeln entspricht die darstellung nicht der realität....

Könnt ihm mir vielleicht weiter helfen und mir sagen wo da der Fehler ist?
Die Formel für den schrägen Wurf habe ich aus meinem Tafelwerk=korrekt.
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mi 29.03.06 17:05 
Du weißt schon, dass die Funktion sin den Winkel in rad. und nicht in Grad erwartet?

AXMD
Dodekaeder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

WinXP,Win95
Delphi 5
BeitragVerfasst: Mi 29.03.06 17:09 
ouh.... d.h.
es muss so heißen?

irgendwas:=tan(radtodeg(alpha))

oder halt mit cos oder sin?
oder wie wäre dafür der tag?

also falls der radtodeg tag richtig sein sollte, ist das Problem damit nicht gelöst...
jetzt verlaufen die kurven etwas anders, aberbei40° hat die kurve mimmernoch einen steileren Anstieg als bei 45°.... :(


Moderiert von user profile iconAXMD: Beiträge zusammengefasst
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mi 29.03.06 17:20 
user profile iconDodekaeder hat folgendes geschrieben:
ouh.... d.h.
es muss so heißen?

irgendwas:=tan(radtodeg(alpha))

oder halt mit cos oder sin?
oder wie wäre dafür der tag?


mach da mal das raus:

radtodeg(tan(alpha));
Dodekaeder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

WinXP,Win95
Delphi 5
BeitragVerfasst: Mi 29.03.06 17:26 
mit
degtorad(cos(45))=30,098
cos(degtorad(45))=-0,5918
cos(45)=0,5253

aber ich brauch einen algorithmus wo für cos(45)=0,707 rauskommt...
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mi 29.03.06 18:16 
das geht genau so:
ausblenden Delphi-Quelltext
1:
  cos(degtorad(45))					
Dodekaeder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

WinXP,Win95
Delphi 5
BeitragVerfasst: Mi 29.03.06 19:36 
jo nach etwas rumprobieren hats funktioniert :lol:

Dankeschön :D