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

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

戻る