简体   繁体   English

欧拉相机,在相机本地系统中绕x轴旋转

[英]Euler camera, rotation around x axis in camera local system

I have camera class that hold her orientation via euler angles and position. 我有一个摄像头课程,可以通过欧拉角和位置来保持她的方向。 Something like that: 像这样:

float m_x;
float m_y;
float m_z;

Vector4 m_pos;

And i want to move this camera free over the space. 我想在空间上自由移动相机。 When user move mouse up-down camera must rotate around x axis in her own coordinate system. 用户上下移动鼠标时,摄像头必须在自己的坐标系中绕x轴旋转。 But i want to hold only this three angles and position and nothing more. 但是我只想保持这三个角度和位置,仅此而已。

So algorithm looks like this: 所以算法看起来像这样:

  1. Find camera local system axis (u, v, n) 查找相机本地系统轴(u,v,n)
  2. Rotate around u axis on angle alpha 围绕u轴以角度alpha旋转
  3. Find angles around (1, 0, 0), (0, 1, 0), (0, 0, 1) that answer to rotation on angle alpha around u axis 查找围绕(1,0,0),(0,1,0),(0,0,1)的角度,这些角度与围绕u轴的角度alpha的旋转有关
  4. Add them to m_x, m_y, m_z 将它们添加到m_x,m_y,m_z

Question is: how can i calculate rotation angles in default coordinate system (i mean in (1, 0, 0), (0, 1, 0) and (0, 0, 1)) that answer to rotation angles in local camera coordinate system? 问题是:如何计算默认坐标系中的旋转角度(我的意思是(1,0,0),(0,1,0)和(0,0,1)),以响应本地相机坐标中的旋转角度系统?

描述

Or may be better solution exists for this problem? 还是针对此问题存在更好的解决方案?

I'm answering the concise question from your comment : 我正在回答您评论中的简洁问题:

how to calculate rotation in one coordinate system that answer to rotation in another coordinate system? 如何计算一个坐标系中的旋转响应另一个坐标系中的旋转?

You can transform rotations between coordinate systems by applying a suitable transformation matrix. 您可以通过应用合适的变换矩阵来变换坐标系之间的旋转。 This in turn can be computed form the euler angles, see the Wikipedia section on conversion formulae . 这又可以通过欧拉角来计算,请参阅Wikipedia上有关转换公式的部分

Depending on your application, you might or might not have to take translations into account as well. 根据您的应用程序,您可能也可能不必考虑翻译。 As I understand your question, you can concentrate on the rotation part of each transformation. 据我了解您的问题,您可以专注于每个变换的旋转部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM