Hi,
I have a entity from CZML datasource. I can get it’s position in Cartesian and orientation in Quaternion.
I have no problem to transform position to lat / lon using “Cesium.Ellipsoid.WGS84.cartesianToCartographic ”.
However, I can’t figure out how to translate quaternion to heading/pitch/roll. (respect to an east-north-up axes centered at the entity position)
Anyone could help?
There doesnt appear to be a method for either quat or mat3 to convert into euler angles. You could convert into mat3 then do manual inverse trig on first column for yaw/pitch then the second or column for roll
abdou
January 29, 2016, 5:23am
3
Hello,
I begun a pull in order to retrieve heading pitch roll from a quaternion:
https://github.com/AnalyticalGraphicsInc/cesium/pull/2536/files
Hi Bob,
Thank you for the HPR to Quaternion. But I still not sure how to further convert the generated HPR(respect to earth-center frame) into an east-north-up frame.
one solution
const scratchInvEastNorthUpFrame = new Matrix4();
const scratchInvRotation = new Matrix3();
const scratchInvRotationQ = new Quaternion();
const scratchLocalQuaternion = new Quaternion();
const scratchLocalHpr = new HeadingPitchRoll();
function getLocalHpr(origin, quaternion) {
const eastNorthUpFrame = Transforms.eastNorthUpToFixedFrame(origin);
const invEastNorthUpFrame = Matrix4.inverse(eastNorthUpFrame, scratchInvEastNorthUpFrame);
const invRotation = Matrix4.getRotation(invEastNorthUpFrame, scratchInvRotation);
const invRotationQ = Quaternion.fromRotationMatrix(invRotation, scratchInvRotationQ);
const localQuaternion = Quaternion.multiply(invRotationQ, quaternion, scratchLocalQuaternion);
return HeadingPitchRoll.fromQuaternion(localQuaternion, scratchLocalHpr);
}