1. Mathematical functions

Hi everyone --

        I'm a little new to the Euphoria world (actually, I've had it for
three months but never have had time to fool around with it!). This is
probably a dumb question.  I'm trying to write a trigonometry program for
my geometry class.  It's supposed to get an angle which the user inputs,
and then it should return the cosine, sine, and tangent of the angle.  It
works fine, except when the numbers are converted to the cosine, sine,
and tangent, they are wrong!!! I've been inputting 35 as a test angle
when trying the program.  The program returns .4738147 as the tangent
(the actual tan of 35 is .7002075)! Help!!

                                Thanks in advance,
                                        Nate Dudek

new topic     » topic index » view message » categorize

2. Re: Mathematical functions

Hi Nathan,

   The problem is that euphoria trigonometrics functions work with
radians not degrees. You have to convert from degrees to radians.

function DegToRad(atom deg)
   return   deg/180*3.1415
end function

function RadToDeg(atom rad)
    return rad/3.1415*180
end function

? sin(DegToRad(35))

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu