class Dogma::Angle

An angle.

@see dogma.dev/Angle/

Attributes

radians[R]

@return [Float]

Public Class Methods

new(degrees: nil, radians: nil, turns: nil) click to toggle source

@param [Float, to_f] degrees @param [Float, to_f] radians @param [Float, to_f] turns @return [void]

# File lib/dogma/angle.rb, line 16
def initialize(degrees: nil, radians: nil, turns: nil)
  @radians = case
    when radians then radians.to_f
    when degrees then degrees.to_f/180 * Math::PI
    when turns then turns * 2*Math::PI
  end
end

Public Instance Methods

as_degrees() click to toggle source

@return [Float]

# File lib/dogma/angle.rb, line 32
def as_degrees
  self.radians/Math::PI * 180
end
as_radians() click to toggle source

@return [Float]

# File lib/dogma/angle.rb, line 38
def as_radians
  self.radians
end
as_turns() click to toggle source

@return [Float]

# File lib/dogma/angle.rb, line 44
def as_turns
  self.radians / (2*Math::PI)
end
to_f() click to toggle source

@return [Float]

# File lib/dogma/angle.rb, line 26
def to_f
  self.radians
end