Я решил этот вопрос, используя 2 поворота вокруг произвольной оси, а затем матрицу LookAt от @ 0x5453. Прикрепленный код, где Mv - конечная матрица 4x4:
`def findWorld2Cam ([x, y, z]):
# EXTRINSIC
camtheta=np.arctan(location[0]/location[2])
T=np.eye(4)
T[0:3,3]=-location
u=[0,1,0]
theta=camtheta
Rtheta=np.array([[np.cos(theta) + u[0]**2* (1 - np.cos(theta)),
u[0]* u[1]* (1 - np.cos(theta)) - u[2]* np.sin(theta),
u[0] *u[2]* (1 - np.cos(theta)) + u[1]* np.sin(theta), 0],
[u[1] *u[0]* (1 - np.cos(theta)) + u[2]* np.sin(theta),
np.cos(theta) + u[1]**2 *(1 - np.cos(theta)),
u[1] *u[2]* (1 - np.cos(theta)) - u[0] *np.sin(theta), 0],
[u[2] *u[0]* (1 - np.cos(theta)) - u[1] *np.sin(theta),
u[2]* u[1] *(1 - np.cos(theta)) + u[0]* np.sin(theta),
np.cos(theta) + u[2]**2 *(1 - np.cos(theta)), 0], [0, 0, 0, 1]])
#u=np.dot(Rtheta,[1,0,0,1])
u=[1,0,0]
camphi=np.arctan(location[1]/location[2])
phi=-camphi
Rphi=np.array([[np.cos(phi) + u[0]**2* (1 - np.cos(phi)),
u[0]* u[1]* (1 - np.cos(phi)) - u[2]* np.sin(phi),
u[0] *u[2]* (1 - np.cos(phi)) + u[1]* np.sin(phi), 0],
[u[1] *u[0]* (1 - np.cos(phi)) + u[2]* np.sin(phi),
np.cos(phi) + u[1]**2 *(1 - np.cos(phi)),
u[1] *u[2]* (1 - np.cos(phi)) - u[0] *np.sin(phi), 0],
[u[2] *u[0]* (1 - np.cos(phi)) - u[1] *np.sin(phi),
u[2]* u[1] *(1 - np.cos(phi)) + u[0]* np.sin(phi),
np.cos(phi) + u[2]**2 *(1 - np.cos(phi)), 0], [0, 0, 0, 1]])
R=np.dot(Rphi,Rtheta)
up1=np.dot(R,[0,1,0,1])
theta=np.arctan(location[0]/location[2])
phi=np.arctan(location[1]/location[2])
l=[0,0,0]
Mt=np.eye(4)
F=l-location
Mt[0:3,3]=-location
forward=F/np.linalg.norm(F)
up=up1[0:3]/np.linalg.norm(up1[0:3])
left=np.cross(up,forward)
Mr=np.eye(4)
Mr[0,0:3]=left
Mr[1,0:3]=up
Mr[2,0:3]=forward
Mv=np.dot(Mr,Mt)
return Mv
`