degrees and radians.

Tim Hammerquist tim at vegeta.ath.cx
Sat May 4 04:27:51 EDT 2002


Jim Richardson graced us by uttering:
> I am trying to get the math module to deal with degrees rather than
> radians. (that it deals with radians for the angular functions like
> sin() isn't mentioned in the docs, which was sort of an eyeopener :)
> I can't find any info on doing this. I can convert from-to degrees in
> the code calling the function, but that's a bit clunky. Any pointers
> to an FM to R? :)

Radians are what trig is based on. Otherwise the formula for the area of
a circle would be 'A = 360r'; since when does a unit circle have an area
of 360 square units?

OTOH, `man 3 sin` on my system documents the sin() function of the C
math library _is_ documented as taking radians. On a POSIX system, this
is usually what is called by Ruby's Math.sin() method.

Can you just write an additional method like

  def sin_d(deg)
    Math.sin(deg * Math::PI / 180)
  end

...and maybe even make it a method of the Math module itself?

Tim Hammerquist
-- 
For every problem, there is one solution which is simple, neat and wrong.
    -- H. L. Mencken



More information about the Python-list mailing list