Sha256: 64167374e5cedbfb547c33e2650c5ec4819437a4874e663b28762e1687aa1b15

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

# encoding: UTF-8
module PrayerTimes
  # Math helpers module
  module MathHelpers
    # Calculates radians from degrees
    # @param [Float] x
    # @return [Float]
    def radians(x) ; x * Math::PI/180 ; end

    # Calculates degrees from radians
    # @param [Float] x
    # @return [Float]
    def degrees(x) ; x * 180/Math::PI ; end

    # Calculates sin in radians
    # @param [Float] x
    # @return [Float]
    def rsin(x); Math.sin(radians x) ; end

    # Calculates cos in radians
    # @param [Float] x
    # @return [Float]
    def rcos(x); Math.cos(radians x) ; end

    # Calculates tan in radians
    # @param [Float] x
    # @return [Float]
    def rtan(x); Math.tan(radians x) ; end

    # Calculates arcsin in degrees
    # @param [Float] x
    # @return [Float]
    def darcsin(x); degrees Math.asin(x) ; end

    # Calculates arccos in degrees
    # @param [Float] x
    # @return [Float]
    def darccos(x); degrees Math.acos(x) ; end

    # Calculates arctan in degrees
    # @param [Float] x
    # @return [Float]
    def darctan(x); degrees Math.atan(x) ; end

    # Calculates arccot in degrees
    # @param [Float] x
    # @return [Float]
    def darccot(x); degrees Math.atan(1.0/x) ; end

    # Calculates arctan2 in degrees
    # @param [Float] x
    # @param [Float] y
    # @return [Float]
    def darctan2(y, x); degrees Math.atan2(y, x) ; end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prayer_times-0.1.1 lib/prayer_times/math_helpers.rb