module DYI::Util

Defines the utility functions in this module.

All the methods defined by the module are ‘module functions’, which are called as private instance methods and are also called as public class methods (they are methods of Math Module like). See also {DYI::Script::EcmaScript::DomLevel2}. @since 1.1.0

Private Instance Methods

acos(x) click to toggle source

Computes the arc cosine of x in degrees. Returns 0 .. 180. @param [Number] x @return [Float] the arc cosine value in degrees @function

# File lib/dyi/util.rb, line 79
def acos(x)
  Math.acos(x) * 180 / Math::PI
end
asin(x) click to toggle source

Computes the arc sine of x in degrees. Returns -90 .. 90. @param [Number] x @return [Float] the arc sine value in degrees @function

# File lib/dyi/util.rb, line 71
def asin(x)
  Math.asin(x) * 180 / Math::PI
end
atan(x) click to toggle source

Computes the arc tangent of x in degrees. Returns -90 .. 90. @param [Number] x @return [Float] the arc tanget value in degrees @function

# File lib/dyi/util.rb, line 87
def atan(x)
  Math.atan(x) * 180 / Math::PI
end
cos(degree) click to toggle source

Computes the cosine of degree (expressed in degrees). @param [Number] degree the value in degrees @return [Float] the cosine of the parameter @function

# File lib/dyi/util.rb, line 55
def cos(degree)
  Math.cos(to_radian(degree))
end
sin(degree) click to toggle source

Computes the sine of degree (expressed in degrees). @param [Number] degree the value in degrees @return [Float] the sine of the parameter @function

# File lib/dyi/util.rb, line 47
def sin(degree)
  Math.sin(to_radian(degree))
end
tan(degree) click to toggle source

Computes the tangent of degree (expressed in degrees). @param [Number] degree the value in degrees @return [Float] the tangent of the parameter @function

# File lib/dyi/util.rb, line 63
def tan(degree)
  Math.tan(to_radian(degree))
end
to_radian(degree) click to toggle source

Converts the value of degree from degrees to radians. @param [Number] degree the value in degrees @return [Float] the value in radians @function

# File lib/dyi/util.rb, line 39
def to_radian(degree)
  Math::PI * degree / 180
end