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

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

戻る