Калькулятор треугольников
Решайте любой треугольник по ССС, СУС, УСУ, УУС. Вычислите площадь и периметр.
Часто задаваемые вопросы
Реализация кода
import math
def deg(angle): return math.radians(angle)
def rad(angle): return math.degrees(angle)
# SSS: all three sides known → find angles and area
def solve_sss(a, b, c):
# Law of cosines
A = rad(math.acos((b**2 + c**2 - a**2) / (2*b*c)))
B = rad(math.acos((a**2 + c**2 - b**2) / (2*a*c)))
C = 180 - A - B
# Heron's formula
s = (a + b + c) / 2
area = math.sqrt(s * (s-a) * (s-b) * (s-c))
return A, B, C, area
A, B, C, area = solve_sss(3, 4, 5)
print(f"Angles: {A:.2f}°, {B:.2f}°, {C:.2f}°")
print(f"Area: {area:.4f}")
# SAS: two sides and included angle
def solve_sas(a, b, C_deg):
C = deg(C_deg)
# Law of cosines for third side
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(C))
# Law of sines for other angles
A = rad(math.asin(a * math.sin(C) / c))
B = 180 - C_deg - A
area = 0.5 * a * b * math.sin(C)
return c, A, B, area
c, A, B, area = solve_sas(5, 7, 60)
print(f"Side c: {c:.4f}, Angles: {A:.2f}°, {B:.2f}°, Area: {area:.4f}")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.