NatNet matlab code - explained?

NatNet, VRPN, TrackD, and Plugins
Post Reply
basf
Posts: 1
Joined: Thu Apr 18, 2024 3:08 pm

NatNet matlab code - explained?

Post by basf »

Hi,

NatNet SDK 4.1.1 provides the following example on how to extract Euler angles from quaternions (Matlab > plotrotation.m)

% Get the rb rotation
rb = evnt.data.RigidBodies( rbnum );
qx = rb.qx;
qy = rb.qy;
qz = rb.qz;
qw = rb.qw;

q = quaternion( qx, qy, qz, qw );
qRot = quaternion( 0, 0, 0, 1);
q = mtimes( q, qRot);
a = EulerAngles( q , 'zyx' );
eulerx = a( 1 ) * -180.0 / pi;
eulery = a( 2 ) * 180.0 / pi;
eulerz = a( 3 ) * -180.0 / pi;

I'm somewhat familiar with 3D rotations and transforms, but I'm at a loss with the conventions used here:

(1) Why do we need to multiply the measured data by qRot?

(2) I'm assuming the axis convention is Y-up when streaming the data? But, why are we multiplying our newfound Euler angles by -1 to get to the final eulerx and eulerz angles?

My system goes on to use different frames for calculations so understanding what is happening here is crucial before manipulating data without going crazy. I've been scouting for an explanation in NatNet docs and here - no luck so far. Any help is much appreciated!!
Post Reply