Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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 1 radiian=180/pi degrees turn it around 1 degree=pi/180 radiians

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

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://73532]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2018-04-25 11:19 GMT
Find Nodes?
    Voting Booth?