python计算三角形定点坐标

x33g5p2x  于2022-07-11 转载在 Python  
字(0.6k)|赞(0)|评价(0)|浏览(401)
import  numpy as np
import matplotlib.pyplot as plt

def getXy(angle=60):

    # print(np.sin(angle/180*np.pi))

    a=0.866

    aa=np.arcsin(a)
    # aaa= round(aa*180/np.pi,2)
    #
    # print (aaa)

    a=1
    b=1

    c=5
    d=5

    distance=np.sqrt(np.square(d-b)+np.square(c-a))/2

    m=(a+c)/2
    n=(b+d)/2

    jijiao=np.arctan((d-b)/(c-a))

    y=n+ distance*np.sin(2*angle/180*np.pi+jijiao)
    x=m+distance*np.cos(2*angle/180*np.pi+jijiao)
    print("x:",x,y)
    # print(jijiao*180/np.pi)
    # print("he:",( np.square(x-a)+np.square(y-b)+np.square(x-c)+np.square(y-d)))
    # print("he2",np.square(c-a)+np.square(d-b))
    # xx=[a,c,x]
# yy=[b,d,y]
# plt.plot(xx,yy)
# plt.show()

getXy(60)
getXy(300)

相关文章