Page 1 of 1

Math function questtion.

Posted: Tue Dec 01, 2009 12:39 pm
by alm2009
Hi,
I have sample code listed below
<?php
echo sin(45);
echo "<br/>";
echo cos(45);
?>

When i run the code, I get the following results:

0.85090352453412
0.52532198881773

Here is the problem, I know that Sin(45)=Cos(45)
So what I'm doing wrong here?
Many Thanks

Re: Math function questtion.

Posted: Tue Dec 01, 2009 12:48 pm
by AbraCadaver
alm2009 wrote:Hi,
I have sample code listed below
<?php
echo sin(45);
echo "<br/>";
echo cos(45);
?>

When i run the code, I get the following results:

0.85090352453412
0.52532198881773

Here is the problem, I know that Sin(45)=Cos(45)
So what I'm doing wrong here?
Many Thanks
Sin(45) NOT EQUAL Cos(45)

Sin(45 deg) EQUAL Cos(45 deg)

And the PHP functions expect radian.

Code: Select all

echo sin(deg2rad(45));
echo cos(deg2rad(45));
-Shawn

Re: Math function questtion.

Posted: Tue Dec 01, 2009 12:54 pm
by alm2009
Thanks a lot, I just realized that the trigonometrical function might not use degrees as a default.
cheers