从3D变换矩阵中提取旋转矩阵

时间:2013-12-15 19:20:22

标签: python matrix

我制作了一段代码,其中包含我在互联网上发现的有关矩阵的一些信息。但我一直坚持从SRT中提取旋转矩阵。

def getRotationMatrix (m):
    scale = m.getScale() #return a Vector4 with the length of every row
    scaleMatrix = PMatrix4() #Initialize the scale matrix 
    for x in xrange (4):
        scaleMatrix[x,x] = scale[x] # set the scale factors on the diagonal
    rm = m*scaleMatrix.inverse() # and multiply the SRT matrice by the inverse
    return rm

在大多数情况下似乎工作正常,但例如对于此输入:

m = [-12.175876450247891, 5.807595155923971, 19.849933782589485, 0.0], [-13.991742515447003, -19.27618605313048, -2.9427525595147523, 0.0], [-15.230862551074761, 13.065239750956977, -13.165118161273075, 0.0], [0.0, 0.0, 0.0, 1.0]

这给我一个错误的结果,第三行是否定的。 我某处错了?

0 个答案:

没有答案