如何从C#中的3x3同构矩阵获得旋转,平移,剪切 [英] How to get rotation, translation, shear from a 3x3 Homography matrix in c#
本文介绍了如何从C#中的3x3同构矩阵获得旋转,平移,剪切的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我计算了3x3单应性矩阵,需要旋转,平移,剪切和缩放以将它们用作Windows8媒体元素属性中的参数?!
I calculated the 3x3 homography matrix and I need to get rotation, translation, shear and scale to use them as parameters in the windows8 media element attributes ?!
推荐答案
请参见 https://math.stackexchange。 com / questions / 78137 / decomposition-a-nonsquare-affine-matrix
def getComponents(normalised_homography):
'''((translationx, translationy), rotation, (scalex, scaley), shear)'''
a = normalised_homography[0,0]
b = normalised_homography[0,1]
c = normalised_homography[0,2]
d = normalised_homography[1,0]
e = normalised_homography[1,1]
f = normalised_homography[1,2]
p = math.sqrt(a*a + b*b)
r = (a*e - b*d)/(p)
q = (a*d+b*e)/(a*e - b*d)
translation = (c,f)
scale = (p,r)
shear = q
theta = math.atan2(b,a)
return (translation, theta, scale, shear)
这篇关于如何从C#中的3x3同构矩阵获得旋转,平移,剪切的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文