语法错误

时间:2016-11-08 07:48:09

标签: python numpy matrix cycle

pts2d = np.array([[1.0486, -0.3645], [-1.6851, -0.4004], [-0.9437, -0.42], [1.0682, 0.0699], [0.6077, -0.0771], [1.2543, -0.6454], [-0.2709, 0.8635], [-0.4571, -0.3645], [-0.7902, 0.0307], [0.7318, 0.6382], [-1.058, 0.3312], [0.3464, 0.3377], [0.3137, 0.1189], [-0.431, 0.0242], [-0.4799, 0.292], [0.6109, 0.083], [-0.4081, 0.292], [-0.1109, -0.2992], [0.5129, -0.0575], [0.1406, -0.4527]])
pts3d = np.array([[1.5706, -0.149, 0.2598], [-1.5282, 0.9695, 0.3802], [-0.6821, 1.2856, 0.4078], [0.4124, -1.0201, -0.0915], [1.2095, 0.2812, -0.128], [0.8819, -0.8481, 0.5255], [-0.9442, -1.1583, -0.3759], [0.0415, 1.3445, 0.324], [-0.7975, 0.3017, -0.0826], [-0.4329, -1.4151, -0.2774], [-1.1475, -0.0772, -0.2667], [-0.5149, -1.1784, -0.1401], [0.1993, -0.2854, -0.2114], [-0.432, 0.2143, -0.1053], [-0.7481, -0.384, -0.2408], [0.8078, -0.1196, -0.2631], [-0.7605, -0.5792, -0.1936], [0.3237, 0.797, 0.217], [1.3089, 0.5786, -0.1887], [1.2323, 1.4421, 0.4506]])
u = pts2d[:,0]
v = pts2d[:,1]
X = pts3d[:,0]
Y = pts3d[:,1]
Z = pts3d[:,2]
A = np.zeros(40,12)
for i in range(1,2,40):
 for j in range ((i + 1) / 2): 
     A[i:i+1, :] = np.concatenate(X[j], Y[j], Z[j]  1, 0, 0, 0, 0 - u[j]*X[j]-u[j]*Y[j]-u[j]*Z[j]-u[j] 0, 0, 0, 0 X[j], Y[j], Z[j], 1 - v[j]*X[j]-v[j]*Y[j]-v[j]*Z[j]-v[j])
{p> v[j]*X[j]出错。为什么我不能将它们相乘?

1 个答案:

答案 0 :(得分:0)

你忘记了一些术语之间的一些逗号,例如:0 X[j] 这可能是您的语法错误来自的地方。 您还需要将所有这些术语放在列表中以便连接起作用。

这里是复制/粘贴的整行;

A[i:i+1, :] = np.concatenate([ X[j], Y[j], Z[j], 1, 0, 0, 0, 0 - u[j]*X[j]-u[j]*Y[j]-u[j]*Z[j]-u[j], 0, 0, 0, 0, X[j], Y[j], Z[j], 1 - v[j]*X[j]-v[j]*Y[j]-v[j]*Z[j]-v[j] ])