XYZ旋转,平移和倾斜 [英] XYZ rotation to pan and tilt

查看:451
本文介绍了XYZ旋转,平移和倾斜的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图控制移动头摄像头从我的电脑有一定的方向。该相机由锅(540度)和倾斜(280度)仅控制。这个问题越来越欧拉角这些平移和倾斜程度。

I am trying to control a moving head camera in a certain direction from my computer. The camera is controlled only by pan (540 degrees) and tilt (280 degrees). The problem is getting the Euler angles to these pan and tilt degrees.

我有一个方向的3D重presentation,假设XY和Z轴旋转(Eurler角度)。

I have a 3d representation of a direction, let's say X Y and Z rotation (Eurler angles).

现在我想将我的(身体!)云台摄像机德同一个方向。但我无法弄清楚如何把一个XYZ载体云台。

Now I want to move my (physical!) pan tilt camera in te same direction. But i can't figure out how to translate an xyz vector to pan tilt.

推荐答案

切换到正交均匀的4×4变换矩阵

switch to orthogonal homogenous 4x4 transform matrices

  • 在欧拉角吮吸复杂memoizing运动。
  • M是你的4x4相机变换矩阵

围绕全球化的世界X轴旋转李安:

rotation around global world X axis by ang:

double c=cos(ang),s=sin(ang);
double Q[16]=
    {
    1, 0, 0, 0,
    0, c,-s, 0,
    0, s, c, 0,
    0, 0, 0, 1
    };
M=M*Q;

各地的地方相机X轴旋转李安:

rotation around local camera X axis by ang:

double c=cos(ang),s=sin(ang);
double Q[16]=
    {
    1, 0, 0, 0,
    0, c,-s, 0,
    0, s, c, 0,
    0, 0, 0, 1
    };
M=((M^-1)*Q)^-1;

有用于变换矩阵状GLM库,但我preFER我自己

there are libraries for transform matrices like glm but i prefer my own

  • 我知道很多人会不同意,但我的是这里比任何其他公众一个
  • ,我习惯了
  • 的想法是要记住的M直接和逆矩阵在任何时候
  • 有哪一个是更新和标志,没有
  • 和之前的任何操作检查,如果所使用的矩阵是相关
  • 如果没有的话,从另外一个计算它
  • 也增加操作次数,并达成treshold
  • 请正交或正交性检查/更正

在这里你可以看到同质(4×4)之间的差异和正常(3×3×3 +)3D变换矩阵:

here you can see the differences between homogenous (4x4) and normal (3x3+1x3) 3D transform matrices:

相机现在的驾驶

  • 在我将把我的形象上面的4×4的那个链接里面变换矩阵
  • 在我通常使用Z轴作为运动/观察方向
  • 因此在开始重置矩阵,单位或者其设置为它的位置和方向,因为你需要
  • 当你想使用旋转局部旋转
  • 当你想要移动只需要添加到位置X0,Y0,Z0要移动的偏置(全局坐标)
  • 所以往前走,如果D单元做到这一点:

  • I will refer to my image inside that link above of 4x4 transform matrix
  • I usually use Z axis as a movement/viewing direction
  • so at start reset your matrix to unit or set it to its position and orientation as you need
  • when you want to rotate use local rotations
  • when you want to move just add to position x0,y0,z0 the ofset you want to move (in global coordinates)
  • so for move forward if d units do this:

x0+=d*Zx;
y0+=d*Zy;
z0+=d*Zz;

  • 有关侧面的运动应使用X矢量

  • for side movement use X vector

    针对不同的旋转然后绕X轴只是用不同的Q矩阵

    for rotations different then around X axis just use different Q matrix

    绕Y轴旋转

     c, 0, s, 0,
     0, 1, 0, 0,
    -s, 0, c, 0,
     0, 0, 0, 1;
    

  • 绕Z轴的旋转

  • rotation around Z-axis

     c,-s, 0, 0,
     s, c, 0, 0,
     0, 0, 1, 0,
     0, 0, 0, 1;
    

  • 这篇关于XYZ旋转,平移和倾斜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆