• ORBITER-FORUM will be temporarily closed at 2026-07-23 18:00 UTC while we complete some OF maintenance tasks. The amount of downtime is expected to take up to one hour, but probably less.

Advanced Question Matrix to Euler angles

Bibi Uncle

50% Orbinaut, 50% Developer
Addon Developer
Joined
Aug 12, 2010
Messages
192
Reaction score
0
Points
0
Location
Québec, QC
Hi everyone!

I need to rotate a ship at its creation by a given angle of pitch, roll and yaw. I send a VECTOR3 that looks like this: _V(90, 0, 0), and my method should rotate the created vessel.

I have no knowledge of Euler angles, and only basic knowledge of matrices.

I managed to create a matrix that rotates the mesh correctly (tested with SetRotationMatrix). However, calling SetRotationMatrix leads to a little "popping" of the mesh (Orbiter doesn't refresh the matrix in the same frame?).

So, I would like to apply the matrix before creating the vessel: in VESSELSTATUS::arot. However, converting the matrix to the Euler angles does not work. I use the described formula in Orbiter API's documentation:

alpha = atan2(R23, R33)
beta = asin(R13)
gamma = atan2(R12, R11)

The results are weird. I can't find any consistency.

What am I doing wrong?
 
This may have been a typo in the documentation. It should be

beta = -asin(R13)

(Hint: You can check that for yourself by solving the equation in the documentation for VESSEL::GetGlobalOrientation for alpha, beta and gamma).

Does that produce better results?
 
Thanks Martin! It's working now with your correction! You should correct it from the doc. I verified and there is a typo in the 100830 version of the API_Reference.chm and API_Reference.pdf.

:thankyou:
 
Back
Top