斜辺と角度から、高さと底辺を計算するサンプル

  1. import math
  2. # 斜辺
  3. hypotenuse = 1
  4. # 角度
  5. angle = 30
  6. # 斜辺と角度から高さを求める
  7. height = hypotenuse * math.sin(math.pi * angle / 180)
  8. # 斜辺と角度から底辺を求める
  9. bottom = hypotenuse * math.cos(math.pi * angle / 180)
  10. print(height)
  11. print(bottom)

戻る