Class: ThetaAngle

Inherits:
Object show all
Includes:
Comparable, Ruuuby::Attribute::Includable::SyntaxCache
Defined in:
lib/ruuuby/math/geometry/theta_angle.rb,
lib/ruuuby/math/geometry/theta_angle.rb,
lib/ruuuby/math/geometry/theta_angle.rb

Overview

terminology:

* radius       | a measurement in distance     |
* arc-length   | a measurement in distance     |
* angle-of-arc | arc-length / radius           | [notice that the output has no units]

vocabulary:

* ephemeral    | lasting for a very short time |

| degree | ° | θ°.new(360) | | radian | ʳ | θʳ.new(2 * ::Math::PI) | | gon | ᵍ | θᵍ.new(400) | | turn | 𝞽 | θ𝞽.new(1) |

Defined Under Namespace

Modules: ContextParamCheck, ContextRuuuby, ContextStr, Pair, Syntax

Constant Summary collapse

SYN_NUM =
"[-]?(\\d+(.\\d+)?)"
UNITS_RAD =
{'urad' => 10000.0, 'mrad' => 1000.0, 'radians' => 1, 'rad' => 1, 'ʳ' => 1}
UNITS_DGR =
{"''" => 3600.0, 'arc-seconds' => 3600.0, "'" => 60.0, 'arc-minutes' => 60.0, '°' => 1}
UNITS_GON =
{'gons' => 1, 'gon' => 1, '' => 1}
UNITS_TRN =
{'turns' => 1, 'trn' => 1}

Instance Method Summary collapse

Methods included from Ruuuby::Attribute::Includable::SyntaxCache

included

Instance Method Details

#to_sString

Returns:



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'lib/ruuuby/math/geometry/theta_angle.rb', line 333

def to_s
  value = self.real
  if .∋?(value)
    value = value.to_i.to_s
  else
    value = value.to_s
  end
  case(self.repr)
  when 3
    "#{value}ʳθ"
  when 4
    "#{value}°θ"
  when 5
    "#{value}𝞽θ"
  when 6
    "#{value}ᵍθ"
  else
    🛑 RuntimeError.new("| c{ThetaAngle}-> m{to_s} w/ self{#{self.to_s}} val{#{self.real.to_s}} repr{#{self.repr.to_s}} had an unrecognized representation value |")
  end
end

#∅?Boolean

Returns true, if ‘self.real == 0`.

Returns:

  • (Boolean)

    true, if ‘self.real == 0`



273
# File 'lib/ruuuby/math/geometry/theta_angle.rb', line 273

def ∅?; self.real.zero?; end

#≈≈(them) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)


317
318
319
320
321
322
323
324
# File 'lib/ruuuby/math/geometry/theta_angle.rb', line 317

def ≈≈(them)
  if them.θ?
    self == them
  else
    🛑flt❓(:them, them)
    self.to_f.≈≈(them)
  end
end