简体   繁体   中英

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. 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)
  2. Rotate around u axis on angle alpha
  3. Find angles around (1, 0, 0), (0, 1, 0), (0, 0, 1) that answer to rotation on angle alpha around u axis
  4. Add them to 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?

描述

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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