Substract Vec3f of quaternion

Hello. I am working on a project that has a default orientation described via a ofVec3f. The data, that come in via osc are quaternions. I want to keep quaternions (avoiding gimbal locks), while adding the default orientation.

Simpler asked: How can I do ofQuaternion::setFromEuler(ofVec3f)?

Any thoughts?

It is easier as I thought. Well, after I figured…

I kept quaternions all way through, so I did not need to transform it to Euler in the first place. I use ofNodes to implement vec3f orientations, get quaternions via .getOrientationQuad()…

To get offset value differences

ofQuaternion qIn (incoming data)
ofQuaternion qOff (offset data)
ofQuaternion qDiff (difference between offset and current data)
quatNode is the actually used element in 3D space

When data are coming in

quatNode.setOrientation(qIn.inverse() * qDiff)

To reset offset
qDiff = qIn * qOff.inverse();
qDiff.normalize();

I used vectors to run it with many gyro data (Motion Capture System).

Hope it helps others too.

1 Like