Flowdock

The Math module contains module functions for basic trigonometric and transcendental functions. See class Float for a list of constants that define Ruby’s floating point accuracy.

Aliases

  • atanh
  • asinh
  • acosh
  • atan2
  • atan
  • asin
  • acos
  • tanh
  • sinh
  • cosh
  • tan
  • sin
  • cos
  • log10
  • log
  • exp
  • sqrt

Constants

E = rb_float_new(exp(1.0))

E = rb_float_new(M_E)

PI = rb_float_new(atan(1.0)*4.0)

PI = rb_float_new(M_PI)

Attributes

Show files where this module is defined (3 files)
Register or log in to add new notes.
March 31, 2009
0 thanks

Input for trigonometric functions must be radians

You must use radians to have the right result. For example to compute the sin of 125 degrees use:

Math.sin(125*Math::PI/180)