from math import *
def Node_Angle(a, b, c):
"""
求出夹角和边长
:param a: a为公共点,
:return: angle为节点的夹角, ab为边长
"""
Vbx = b[0] - a[0]
Vby = b[1] - a[1]
Vcx = c[0] - a[0]
Vcy = c[1] - a[1]
angle_line = (Vbx * Vcx + Vby * Vcy) / sqrt((Vbx * Vbx + Vby * Vby) * (Vcx * Vcx + Vcy * Vcy) + 1e-10)
# 节点夹角
angle = acos(angle_line) * 180.0 / pi
# 边长ab
ab = float(sqrt(pow((a[0] - b[0]), 2) + pow((a[1] - b[1]), 2)))
return round(angle, 3), ab
a = [0, 3]
b = [0, 0]
c = [4, 0]
# ===========================
print(Node_Angle(a, c, b))
结果如下:
(53.13, 5.0)
# ===========================
print(Node_Angle(c, a, b))
结果如下:
(36.87, 5.0)