import numpy as np
def equilateral(x, y):
v_x = (x[0]+y[0]+np.sqrt(3)*(x[1]-y[1]))/2 # This computes the `x coordinate` of the third vertex.
v_y = (x[1]+y[1]+np.sqrt(3)*(x[0]-y[0]))/2 #This computes the 'y coordinate' of the third vertex.
z = np.array([v_x, v_y]) #This is point z, the third vertex.
return z
为了获得第三个顶点,可以围绕点(x1,y1,…)旋转点(x2,y2,…)60度。另一个可接受的解决方案将在旋转-60度的情况下获得,即在相反方向上
所以只要把y绕x旋转60/-60度,你就有了第三个坐标
您可以使用以下程序实现这一点。 如果点之间的距离相等,也可以将代码展开为测试
相关问题 更多 >
编程相关推荐