The stupid question is the question not asked PerlMonks

### Re: whats up with the sin stuff?

by repson (Chaplain)
 on Apr 18, 2001 at 19:23 UTC ( #73532=note: print w/replies, xml ) Need Help??

in reply to whats up with the sin stuff?

Quite simple, perl (and most other programming languages) take angles for trig functions in radians, while calculators take them in degrees, radians or gradians (usually). Most people prefer degrees, but radians are nicer to mathamaticians and other similar people.

The best thing for you to do is

```use Math::Trig;

\$num = sin( deg2rad( 45 ) );
I think Math::Trig is part of the standard perl distribution, so read the documentation and go for it.

Update: I know about the math of radians as jepri explained but after the amount of it i've done at school recently I didn't feel like providing an explanation.

Replies are listed 'Best First'.
Re: Re: whats up with the sin stuff?
by jepri (Parson) on Apr 19, 2001 at 10:29 UTC
Or you could just divide or multiply by pi/180 (depending on whether you are converting to or from).

It helps to know that there are 2*pi radians in circle. So the math goes like this:

```(radiians)2*pi=360(degrees)
pi=180
turn it around

I tend to work in radiians, since it's easier for a few things.

____________________
Jeremy
I didn't believe in evil until I dated it.

Create A New User
Node Status?
node history
Node Type: note [id://73532]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2017-11-20 21:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
In order to be able to say "I know Perl", you must have:

Results (294 votes). Check out past polls.

Notices?