Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

[SOLVED]Convert 3x3 matrix radians to euler degrees

Featured Replies

  • Author
  • Localization

h3x3r, posted Sun Sep 25, 2022 12:20 pm (73578)


Helo there. Can somebody please mod/update the templete to convert 3x3 matrix radians to euler degrees or radians and output them as X,Y,Z ?
I have made a template for 010 Editor which parse data but i can't figure out code for converting matrices to euler.
Order should be ZYX.
Here's Template to mod. Thanks in advance!
Code:
uint64 PHYSICS_MDL_TABLE_COUNT,NULL;
struct{
struct {
    float m00, m01, m02, m03,
          m10, m11, m12, m13,
          m20, m21, m22, m23,
          POS_X,POS_Y,POS_Z,VAL12;
     uint FILE_ID0,FILE_ID1,FILE_ID0_TMP,FILE_ID1_TMP;
          Printf("File ID = %u File ID1 = %u\n%f  %f  %f  %f\n%f  %f  %f  %f\n%f  %f  %f  %f\nPos X = %f\nPos Y = %f\nPos Z = %f\n\n",FILE_ID0,FILE_ID1,m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23,POS_X,POS_Y,POS_Z);
          }POS_XYZ[PHYSICS_MDL_TABLE_COUNT];
    }PHYSICS_MDL_POS_TABLE;


BTW i used this online converter
Code:
http://www.andre-gaschler.com/rotationconverter/
which works, but i am not sure how precise it is. So i would like to see real values from a file.
EDiT: Here's some code in C
Code:
// Checks if a matrix is a valid rotation matrix.
bool isRotationMatrix(Mat &R)
{
    Mat Rt;
    transpose(R, Rt);
    Mat shouldBeIdentity = Rt * R;
    Mat I = Mat::eye(3,3, shouldBeIdentity.type());

    return  norm(I, shouldBeIdentity) < 1e-6;

}

// Calculates rotation matrix to euler angles
// The result is the same as MATLAB except the order
// of the euler angles ( x and z are swapped ).
Vec3f rotationMatrixToEulerAngles(Mat &R)
{

    assert(isRotationMatrix(R));

    float sy = sqrt(R.at(0,0) * R.at(0,0)   R.at(1,0) * R.at(1,0) );

    bool singular = sy < 1e-6; // If

    float x, y, z;
    if (!singular)
    {
        x = atan2(R.at(2,1) , R.at(2,2));
        y = atan2(-R.at(2,0), sy);
        z = atan2(R.at(1,0), R.at(0,0));
    }
    else
    {
        x = atan2(-R.at(1,2), R.at(1,1));
        y = atan2(-R.at(2,0), sy);
        z = 0;
    }
    return Vec3f(x, y, z);

}


EDiT:
After some digging i finally found solution.
Used GNU Octave with this code:
Code:
function convert_3x3mat2eul
R = [-0.001869 -0.003010 -0.999994; -0.022299 0.999747 -0.002945; 0.999750 0.022276 -0.001943];
[x,y,z] = decompose_rotation(R);
digits(10);
x0 = rad2deg(x);y0 = rad2deg(y);z0 = rad2deg(z); # code for converting radians to degrees
RotX = vpa(x0), RotY = vpa(y0), RotZ = vpa(z0)   # final code for more output digits
end

function [x,y,z] = decompose_rotation(R)
x = atan2(R(3,2), R(3,3));
y = atan2(-R(3,1), sqrt(R(3,2)*R(3,2) R(3,3)*R(3,3)));
z = atan2(R(2,1), R(1,1));
end
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.