Board index » delphi » Sin, Cos, Tan Error in delphi 3 C/S
Finn Panvig
Delphi Developer 
Mon, 30 Apr 2001 03:00:00 GMT

Finn Panvig
Delphi Developer 
Mon, 30 Apr 2001 03:00:00 GMT
Sin, Cos, Tan Error in delphi 3 C/S
Hi, I have problems with the functions: Sin(X), Cos(X) and Tan(X).
When I use them the result is in radians and that is ok. But when I try to Does anyone know anything about this problem. ???? I use RadToDeg and RadToGrad functions..... Finn Panvig 
TBeekhu
Delphi Developer 
Mon, 30 Apr 2001 03:00:00 GMT
Re:Sin, Cos, Tan Error in delphi 3 C/SIm Artikel <4RC22.203$JY4.1...@news.get2net.dk>, "Finn Panvig" Quote>When I use them the result is in radians and that is ok. But when I try to Regards, Torsten. 
Finn Panvi
Delphi Developer 
Tue, 01 May 2001 03:00:00 GMT
Re:Sin, Cos, Tan Error in delphi 3 C/SOk, here is a sample: I put a lable on a form and write the following small code: label1.caption := FloatToStr(Sin(5)); This returns: 0,9589242746631 and this is ok because delphi returns result But if I write the following code: label1.caption := FloatToStr(RadToDeg(Sin(5))); it returns: 54,9423138108416 And this is wrong because making the same calculation on my calculator or in 0,08715574274766 And if I write the following code: label1.caption := FloatToStr(RadToGrad(Sin(5))); The result is: 61,0470153453795 Again wrong, and this goes with Cos as well Therefore Tangent calculations will also be wrong because Remeber that as long as I want to use Sin and Cos as radians (delphi Funny enough I dont get any bad calculaitions when ever I try to calc Simple because I have right calc's in Sin(X) I have wondering if Delphi's Finn Panvig TBeekhuis skrev i meddelelsen Quote

Dr John Stockto
Delphi Developer 
Tue, 01 May 2001 03:00:00 GMT
Re:Sin, Cos, Tan Error in delphi 3 C/SJRS: In article <4RC22.203$JY4.1...@news.get2net.dk> of Thu, 12 Nov 1998 16:08:49 in news:comp.lang.pascal.delphi.misc, Finn Panvig Quote<fpan...@get2net.dk> wrote: the results are pure numbers not in angular measure. ( HELP ArcCos was wrong in BP7; is it OK in D1..D4 ? )  
Earl F. Glyn
Delphi Developer 
Tue, 01 May 2001 03:00:00 GMT
Re:Sin, Cos, Tan Error in delphi 3 C/SQuoteFinn Panvig wrote in message ... The INPUT to sin, cos, tan is in radians. The output is a just a number. For SIN and COS the OUTPUT ranges from 1 to +1. For TAN the output ranges from infinity to +infinity. Quote>But if I write the following code: So this answer is 0,9589242746631 * 180 / PI = what you have above Quote>And this is wrong because making the same calculation on my calculator or in Quote>windows calculator the result is: SIN(5 degrees) is 0.87155... SIN(5 radians) is the value you showed above Do you want SIN( DegToRad(5) ) ? This is the SIN(5 degrees). DegToRad(5) converts 5 degrees to the appropriate number of radians, which Quote>And if I write the following code: So, 200*0,9589242746631 /PI is exactly what you reported. The Delphi math really is correct! (By the way, if you have Delphi 3 C/S you can do a Start  Find  Quote>Simple because I have right calc's in Sin(X) I have wondering if Delphi's efg Earl F. Glynn EMail: EarlGl...@att.net 
Finn Panvi
Delphi Developer 
Tue, 01 May 2001 03:00:00 GMT
Re:Sin, Cos, Tan Error in delphi 3 C/SWell, whatever what kind of pocket calculator I use, the result differs from delphi. But other calculaters result's is allways the same. Earl F. Glynn skrev i meddelelsen <72g2a8$...@bgtnsc02.worldnet.att.net>... Quote>Finn Panvig wrote in message ... 
Tim Rober
Delphi Developer 
Tue, 01 May 2001 03:00:00 GMT
Re:Sin, Cos, Tan Error in delphi 3 C/SQuote"Finn Panvig" <fpan...@get2net.dk> wrote: showed us does not perform the same operation you performed on your pocket calculator. That's why the results differ. When your pocket calculator is in degrees mode: What you're doing is altering the meaning of "5", not the meaning of "sin". In your code, you tried to do this: label1.caption := FloatToStr(RadToDeg(Sin(5))) The Sin function in Delphi ALWAYS expects radians. So, your statement I presume what you want to do is to compute the sine of 5 degrees. Since label1.caption := FloatToStr(Sin(DegToRad(5))); THAT should produce a number very close to 0.087155, which should match  Tim Roberts, t...@probo.com 