0
votes

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?

Description

Or may be better solution exists for this problem?

1
I'd highly suggest looking at quaternions, euler angles are rarely good for cameras, especially if you plan on rotating around all 3 axis.sradforth
thank you, i will, but anyway: how to calculate what i want? :)acrilige
It's a bit unclear what you actually want to do, is the camera her throughout the text? Besides that you're trying to do will net you a result which you most likely don't want, look up gimbal lock.Ylisar
Yes. I can rephrase my question: how to calculate rotation in one coordinate system that answer to rotation in another coordinate system?acrilige
Answering the concise question from your comment, you can transform rotations between coordinate systems by applying a suitable transformation matrix. This in turn can be computed form the euler angles, see Wikipedia.MvG

1 Answers

1
votes

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.