0
我有一個由alpha1,a1 .... theta4表示的常量列表。矩陣乘法浮點數
我可以正確打印並讀取各個矩陣,但是當我嘗試矩陣乘法時收到錯誤;
print T1 * T2 * T3 * T4
TypeError: can't multiply sequence by non-int of type 'list'
我相信這是乘法浮動的事情。
from numpy import matrix
import math
def getTransformationMatrix(alpha, a, d, theta):
transformationMatrix = matrix([[math.cos(theta),math.cos(alpha)*math.sin(theta),math.sin(alpha)*math.sin(theta) ,a*math.cos(theta)], [math.sin(theta),math.cos(alpha)*math.sin(alpha) ,-math.sin(alpha)*math.cos(theta),a*math.sin(theta)],[0,math.sin(alpha),math.cos(alpha),d],[0,0,0,1]])
return[transformationMatrix];
T1 = getTransformationMatrix(alpha1, a1, d1, theta1)
T2 = getTransformationMatrix(alpha2, a2, d2, theta2)
T3 = getTransformationMatrix(alpha3, a3, d3, theta3)
T4 = getTransformationMatrix(alpha4, a4, d4, theta4)
print T1 * T2 * T3 * T4
完美謝謝!並感謝您的類型()提示! – Tommy
很高興我幫了忙。歡迎來到SO。 –