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

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

戻る