We help IT Professionals succeed at work.

Question about Delphi function Tan and Cos

junnz
junnz asked
on
What results are we get from Delphi's Tan and Cos functions? And how can we convert them into real degrees?
Comment
Watch Question

CERTIFIED EXPERT
Commented:
The results cannot be converted to degrees because the results are absolute values (they have to units).

Now, if you want to use degrees as the parameter of the angle, just convert the degrees to radians, like:

rad_angle = deg_angle * PI / 180

thus:
Cos 45? = Cos(45 * PI / 180)

Cos 180? = Cos(180 * PI / 180)

Therefore, supposing X is in degrees, then:

cosine of X in degrees = Cos(X * PI / 180);

The same goes for Sin, Tan, ArcTan, etcetera.

Remember that all the trig functions in Delphi take angles in Radians, not in degrees.

Yours,

Alex

Author

Commented:
I can't believe it that your answer came so quickly.
Thank you very much!

Jun