Computing Euler Angles from MoCap Markers 3D Data

11 views (last 30 days)
I have obtained 3D (x,y,z) data from a Motion Capture (MoCap) system using markers placed on the subject's head and chin. The data is structured in the following format. I need to compute the Euler angles (yaw, pitch, and roll). Any assistanse in this matter would be greatly appreciated.
headFL = [data.HeadFL_X, data.HeadFL_Y, data.HeadFL_Z];
headFR = [data.HeadFR_X, data.HeadFR_Y, data.HeadFR_Z];
headBL = [data.HeadBL_X, data.HeadBL_Y, data.HeadBL_Z];
headBR = [data.HeadBR_X, data.HeadBR_Y, data.HeadBR_Z];
chin = [data.Chin_X, data.Chin_Y, data.Chin_Z];
headFL = [-97.507,-105.897,1594.74]
headFR = [-186.455,-9.66,1609.556]
headBL = [20.236,-15.579,1544.697]
headBR = [-86.745, 98.811,1557.386]
Chin = [-169.193,-74.004,1431.651]

Accepted Answer

Simar
Simar on 12 Jun 2024
Hi Allah,
I understand that you have collected 3D Spatial data from a MoCap system and want to compute the Euler Angles (yaw, pitch, and roll)
Following is a simplified example for calculating Euler angles. The data originates from markers positioned on specified locations around the head: front-left (FL), front-right (FR), back-left (BL), back-right (BR), and chin. Objective is to determine orientation of head using these angles. Given marker positions:
  • headFL = ([-97.507, -105.897, 1594.74])
  • headFR = ([-186.455, -9.66, 1609.556])
  • headBL = ([20.236, -15.579, 1544.697])
  • headBR = ([-86.745, 98.811, 1557.386])
  • Chin = ([-169.193, -74.004, 1431.651])
Step 1: Define Vectors
First, compute vectors that define the head's orientation:
  • Forward Vector ((F)): Points from the back to the front of the head.
  • Upward Vector ((U)): Points from the chin upwards.
  • Rightward Vector ((R)): Orthogonal to both (F) and (U), pointing from the head's left to right.
Step 2: Calculate Basis Vectors
Using the given marker positions, calculate the basis vectors:
% Define marker positions
headFL = [-97.507, -105.897, 1594.74];
headFR = [-186.455, -9.66, 1609.556];
headBL = [20.236, -15.579, 1544.697];
headBR = [-86.745, 98.811, 1557.386];
chin = [-169.193, -74.004, 1431.651];
% Calculate midpoints for simplicity
headFront = (headFL + headFR) / 2;
headBack = (headBL + headBR) / 2;
headTop = (headFL + headFR + headBL + headBR) / 4;
% Forward vector (F)
F = headFront - headBack;
F = F / norm(F); % Normalize
% Upward vector (U)
U = headTop - chin;
U = U / norm(U); % Normalize
% Rightward vector (R) - orthogonal to F and U
R = cross(U, F); % Cross product
R = R / norm(R); % Normalize
% Adjust U for orthogonality
U = cross(F, R);
U = U / norm(U);
Step 3: Compute Euler Angles
With basis vectors defined, calculate Euler angles. Assuming ZYX rotation order (yaw around Z, pitch around Y, roll around X):
% Yaw (around Z)
yaw = atan2(R(2), R(1));
% Pitch (around Y)
pitch = atan2(-F(3), sqrt(F(1)^2 + F(2)^2));
% Roll (around X)
roll = atan2(U(3), sqrt(U(1)^2 + U(2)^2));
Step 4: Convert to Degrees
Finally, convert the angles from radians to degrees for easier interpretation:
yaw_deg = rad2deg(yaw);
pitch_deg = rad2deg(pitch);
roll_deg = rad2deg(roll);
% Display the results
fprintf('Yaw: %f degrees\n', yaw_deg);
Yaw: -48.267532 degrees
fprintf('Pitch: %f degrees\n', pitch_deg);
Pitch: -19.133081 degrees
fprintf('Roll: %f degrees\n', roll_deg);
Roll: 70.752575 degrees
The example demonstrates calculating Euler angles representing orientation of a head model based on MoCap data. The angles provide insight into how the head is oriented in space, which can be crucial for various applications, from animation to biomechanical analyses.
Please refer to the following documentation links-
Hope it helps!
Best Regards,
Simar

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!