def cal_degree(p1, p2, p3): """ 计算p1-p2-p3构成的角度 先计算边长,然后根据cosB = (a*a + c*c -b*b) / (2*a*c) """ x1, y1 = p1 x2, y2 = p2 x3, y3 = p3 a = math.sqrt(pow(x2 - x3, 2) + pow(y2 - y3, 2)) b = math.sqrt(pow(x1 - x3, 2) + pow(y1 - y3, 2)) c = math.sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)) cosB = (a * a + c * c - b * b) / (2 * a * c) B = math.degrees((math.acos(cosB))) # 先弧度再角度 return B
标签:pow,sqrt,角度,坐标,y1,三角形,y2,y3,math From: https://www.cnblogs.com/EstherLjy/p/16966280.html