오일러 행렬을 사용하여 롤 (또는 원통)을 회전하려고합니다. 그 목적을 위해 다음 함수를 사용합니다. 오일러 회전 매트릭스이며 Euler = np.array([[1,0,0],[0,1,0],[0,0,1]])
함수의 입력은 x, y, z = roll(1, -2, 2, np.array([[1,0,0],[0,1,0],[0,0,1]]))
을 때파이썬에서 오일러 매트릭스를 사용하는 객체의 회전
def roll(R, zi, zf, Euler):
# R is the radius of the cylinder
# t is the angle which is running from 0 to 2*pi
# zi is the lower z co-ordinate of cylinder
# zf is the upper z co-ordinate of cylinder
t = np.arange(0, 2* np.pi + 0.1, 0.1)
z = np.array([zi, zf])
t, z = np.meshgrid(t, z)
p, q = t.shape
r = R* np.ones([p,q], float)
# polar co-ordinates to Cartesian co-ordinate
x, y, z = pol2cart(r,t,z)
# Euler rotation
rot0 = np.array([x[0,:], y[0,:], z[0,:]])
rot1 = np.array([x[1,:], y[1,:], z[1,:]])
# mult is the matrix multiplication
mat0 = mult(Euler, rot0)
mat1 = mult(Euler, rot1)
#
x[0,:] = mat0[0,:]
y[0,:] = mat0[1,:]
z[0,:] = mat0[2,:]
#
x[1,:] = mat1[0,:]
y[1,:] = mat1[1,:]
z[1,:] = mat1[2,:]
#
return x, y, z
기능이 잘 작동한다. ax.plot_surface(x,y,z)
을 사용하여 다음 그림을 얻었습니다.
하지만 오일러 매트릭스 Euler = np.array([[1,0,0],[0,1/np.sqrt(2),-1/np.sqrt(2)],[0,1/np.sqrt(2),1/np.sqrt(2)]])
으로 개체를 회전하려고하면 예기치 않은 결과가 나타납니다.
45
정도이다.
일반적으로 np.dot는 행렬 곱셈입니다. 왜 멀티를 사용합니까, 어떤 모듈에서 가져올 수 있습니까? –
나는 그것을 몰랐다. 그래서 저는 행렬 곱셈을위한 함수를 작성했습니다. –
무엇이 멀티입니까? –