I am posting here even though this isn't technically a game development question, but involves quaternions.

I have a 9-axis sensor which gives me a world-frame (gravity, magnetic-north) quaternion representing it's orientation. It's mounted on the laces of a running shoe (meaning there is a 'pitch' offset for the sensor, relative to the shoe). Which means that the axis of rotation of the sensor and of the shoe are different. If I 'roll' the shoe along it's lengthwise axis, then the sensor traces out a cone, with the quaternion returning the x,y,z,w components for that cone.

What I'd like is the 'equivalent' quaternion for the axis of the shoe. Ultimately, deriving Pitch, Roll, Yaw for some of our (non)quaternion metrics, like pronation.

Appreciate any pointers, as what I've tried thus far doesn't seem to be working.

Thanks! -Tim


1 Answer 1


I would just convert the quaternion to a 4x4 or 3x3 matrix first.

The three rows in that matrix are the sensor's X-axis, Y-axis and Z-axis.

Let's say the shoe is tilted in the sensor's Y, then just multiply the matrix with a rotation matrix to undo that tilt.

In pseudo code:

mat44 sensormat = mat44( sensorquat );
vec4  sensory = sensormat.getRow( 1 );
mat44 rotmat = mat44::make_rot( sensory, tiltangle );
mat44 shoemat = sensormat * rotmat;
vec4  shoex = shoemat.getRow(0);
vec4  shoey = shoemat.getRow(1);
vec4  shoez = shoemat.getRow(2);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .