我正在尝试根据指令数据库旋转沿Y轴定向的unit矢量A。
向量被描述为((x1,x2),(y1,y2)。
A = np.array([ 0 ,0 ] , [ 0 , 1 ] )
Database = ['left', 'right', 'right', ... ]
例如,如果我们顺时针旋转4次,我们应该得到:
#First spin
[(0,1),(0,0)]
#Second spin
[(0,0),(0,-1)]
#third spin
[(0,-1),(0,0)]]
#fourth spin
[(0,0),(0,1)]
您可以通过将向量乘以rotation matrix来旋转向量。给定的示例将初始矢量逆时针旋转30度(如在直角坐标系中为正角):
A = np.array([ 0 , 1])
theta = np.radians(30)
c, s = np.cos(theta), np.sin(theta)
R = np.array(((c,-s), (s, c)))
A = np.dot(R, A)