Autor Beitrag
K.S.M.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

Windows 7 Professional
Delphi 2010, HTML, JavaScript, CSS, PHP, ein wenig C, Flash ActionScript 2.0/3.0, SQL, Assembler
BeitragVerfasst: So 10.08.08 14:34 
Hallo! :D

Ich habe folgenden Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var
  Input : Extended;
begin
  Input := StrToFloat( Edit1.Text );       // Edit1.Text = '90'
  Label1.Caption := Format( 'Sinus   : %.4f', [sin(Input)] );  // Label1.Caption = 'Sinus: 0,8940'
  Label2.Caption := Format( 'Kosinus : %.4f', [cos(Input)] );  // Label2.Caption = 'Kosinus: -0,4481'
  Label3.Caption := Format( 'Tangens : %.4f', [tan(Input)] );  // Label3.Caption = 'Tangens: -1,9952'
end;


Die Ergebnisse sind falsch! Sie stimmen nur, wenn man Sinus, Kosinus und Tangens von 0 berechnet.
Weiß jemand, was da falsch läuft?


Moderiert von user profile iconChristian S.: Topic aus VCL (Visual Component Library) verschoben am So 10.08.2008 um 14:38

_________________
"Programmieren ist keine Kunst. Programmieren ist eine Fähigkeit!"
nagel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 708

Win7, Ubuntu 10.10

BeitragVerfasst: So 10.08.08 14:38 
Die Winkelfunktionen erwarten das Argument im Bogenmaß. Du kannst deine Angabe im Gradmaß mit DegToRad umrechnen (oder auch einfach winkel/180*pi).
K.S.M. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

Windows 7 Professional
Delphi 2010, HTML, JavaScript, CSS, PHP, ein wenig C, Flash ActionScript 2.0/3.0, SQL, Assembler
BeitragVerfasst: So 10.08.08 14:42 
Ah! Vielen Dank! :D

_________________
"Programmieren ist keine Kunst. Programmieren ist eine Fähigkeit!"
giantdwarf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35


Delphi 5, Delphi 2006 Prof, Delphi 2009
BeitragVerfasst: Di 12.08.08 10:35 
Die trigonometrischen Funktionen rechnen nicht mit Grad sondern Radiant, d.h. wenn Du den Sinus von 90° ausrechnen willst, musst Du erst 90° in Radiant, d.h. Pi/2, umrechnen.
giantdwarf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35


Delphi 5, Delphi 2006 Prof, Delphi 2009
BeitragVerfasst: Di 12.08.08 10:40 
Ups, hatte garnicht gesehen, dass die Antwort schon gegeben war. Naja, doppelt hält besser. :wink: