Skip to content
Daisuke YAMAGUCHI edited this page Sep 7, 2016 · 4 revisions

要約

siren では、 配列を表す Ruby の組み込みクラス Float クラスを拡張して、2次元幾何演算処理に便利なメソッドを提供しています。ここでは、 siren 独自の拡張機能のみを掲載しています。

インスタンスメソッド


度・ラジアン値の相互変換

to_rad -> Float
to_deg -> Float

to_rad は、Float の値を度(℃)とした場合のラジアン値に変換したものを返します。to_deg は、Float の値をラジアン値とした場合の度(℃)に変換したものを返します。

例)

# 度をラジアン値に変換
45.0.to_rad
  # => 0.78539816339745

# ラジアン値を度に変換
1.5707963267949.to_deg
  # => 90

Clone this wiki locally