Autor Beitrag
Michael15
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76

Win XP Professional
Delphi 2, 3, 7, 8
BeitragVerfasst: Di 15.03.05 19:10 
Gibt es eine einfache Formel in Delphi zum Satz des Pythagoras???
Oder zum Höhensatz des Euklid???
en!gma
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 378

win xp
delphi 7.0
BeitragVerfasst: Di 15.03.05 19:13 
ist pythagoras an sich nicht schon einfach :?:
Michael15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76

Win XP Professional
Delphi 2, 3, 7, 8
BeitragVerfasst: Di 15.03.05 19:14 
ja, aber unser Lehrer möchte das so haben
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Di 15.03.05 19:16 
Eine Formel in Delphi Syntax? c := sqrt(sqr(a)+sqr(b))?
Michael15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76

Win XP Professional
Delphi 2, 3, 7, 8
BeitragVerfasst: Di 15.03.05 19:18 
es ist ja richtig, dass "sqr" ^2 bedeutet und sqrt = wurzel, aber wie bekomme ich die 5te Wurzel einer Zahl. (Und wie mache ich das mit der Formel???
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Di 15.03.05 19:22 
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Di 15.03.05 19:23 
user profile iconMichael15 hat folgendes geschrieben:
aber wie bekomme ich die 5te Wurzel einer Zahl
5. Wurzel beim Pythagoras? :shock: Du zerstörst gerade mein gesamtes mathematisches Grundwissen...
However: Power(123, 1/5);

Zitat:
Und wie mache ich das mit der Formel???
Welcher Formel?

_________________
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
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Di 15.03.05 19:24 
Entweder a^b = exp(b*ln(a));, oder besser a^b = Power(a,b); (unit Math) mit Power kannst du auch negative, ganzzahlige Basen haben.
en!gma
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 378

win xp
delphi 7.0
BeitragVerfasst: Di 15.03.05 19:24 
ausblenden Delphi-Quelltext
1:
edit_c := (sqr(edit_a)+sqr(edit_b))^(1/edit_wurzelzahl)					
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Di 15.03.05 19:25 
Mir ist keine extraFormel bekannt, aber wo liegt das Problem es per Hand auszurechnen?!

So ne Function würde doch schon reichen:

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:
uses math;

function Phytagoras(a,b,c : string) : extended;
var a1,b1,c1, AVal : extended;
begin
 if (c = (uppercase('x')) then
  begin
   a1 := Power(StringToFloat(a), 2);
   b1 := Power(StringToFloat(b), 2);
   AVal := (a1 + b1);
   Result := Power(AVal, 0.5);
  end;  
 if (b = (uppercase('x')) then
  begin
   a1 := Power(StringToFloat(a), 2);
   c1 := Power(StringToFloat(c), 2);
   AVal := (c1 - al);
   Result := Power(AVal, 0.5);
  end;
 if (a = (uppercase('x')) then
  begin
   b1 := Power(StringToFloat(b), 2);
   c1 := Power(StringToFloat(a), 2);
   AVal := (c1 - b1);
   Result := Power(AVal, 0.5);
  end;
end;


Wenn man nun ein Dreieck hat, bei dem die Hypothenuse 5.4 LE, und der Schenkel a = 4.4 LE dann ist der Schenkel b:

ausblenden Delphi-Quelltext
1:
 Showmessage(FloatToString(Pythagoras('4.4', 'x', '5.4');					


ungetestet!

edit: oha, da haben ja schon einige geschrieben. Ja ich war wieder zu ausführlich.
Michael15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76

Win XP Professional
Delphi 2, 3, 7, 8
BeitragVerfasst: Di 15.03.05 19:27 
danke
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Di 15.03.05 19:30 
Man sollte sqrt() und sqr() verwenden, x*x ist langsamer, Power(x,2) erst recht.
@en!gma: "^" kann man nur im Zusammenhang mit Pointern verwenden ;)
en!gma
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 378

win xp
delphi 7.0
BeitragVerfasst: Di 15.03.05 19:35 
hopsala : /
dann halt ich mich lieber raus ^^
wdbee
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 628
Erhaltene Danke: 1



BeitragVerfasst: Di 15.03.05 19:42 
Wenn es etwas anspruchsvoller sein soll, was die Genauigkeit angeht:

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:
//==========================================================================*
// Special version of Pythagoras to prevent over/underflow
//--------------------------------------------------------------------------*
function ptgrs(a, b: extended): extended;
var
  c: extended;
begin
  a := Abs(a);
  b := Abs(b);

  if a > b then
  begin
    c := b / a;
    Result := a * Sqrt(1.0 + c*c);
  end
  else
  begin
    if b = 0.0 then
      Result := 0.0
    else
    begin
      c := a / b;
      Result := b * Sqrt(1.0+c*c);
    end;
  end;
end;
//==========================================================================*
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Di 15.03.05 19:48 
Der Code ist richtig gut :shock:
Da wäre ich ich jetzt definitiv nie drauf gekommen :lol:
OneOfTen
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 15.03.05 19:50