Find Angle MBC

  • + 0 comments

    I had to refresh high school trigonometry.

    from math import sqrt, cos, acos, asin, sin, degrees
    
    ab = float(input())
    bc = float(input())
    
    # Pythagoras theorem
    ac = sqrt(ab**2 + bc**2)
    mc = ac/2
    
    # definition of cos and sin, delta is angle ACB
    cos_delta = bc/ac
    sin_delta = ab/ac
    
    # law of cosines to find mb
    mb = sqrt(bc**2 + mc**2 - 2*bc*mc*cos_delta)
    
    # law of sines to find sin_theta
    sin_theta = (mc*sin_delta)/mb
    
    print(f"{round(degrees(asin(sin_theta)))}\N{DEGREE SIGN}")