首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在c#中从3x3单应矩阵获得旋转、平移和剪切

如何在c#中从3x3单应矩阵获得旋转、平移和剪切
EN

Stack Overflow用户
提问于 2013-03-15 05:37:28
回答 1查看 10.6K关注 0票数 4

我计算了3x3单应矩阵,需要获得旋转、平移、剪切和缩放,才能将它们用作windows8媒体元素属性中的参数?!

EN

回答 1

Stack Overflow用户

发布于 2013-04-18 22:12:40

请参阅https://math.stackexchange.com/questions/78137/decomposition-of-a-nonsquare-affine-matrix

代码语言:javascript
复制
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)
票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15420693

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档