Recovering HeadingPitchRoll from Quaternion


I have searched for the answer to this via Google and in this group. No joy…

Having created a sampled property containing a quaternion created from location and heading, pitch and rolls (via the code below)

date, Cesium.Transforms.headingPitchRollQuaternion(
center, Cesium.HeadingPitchRoll.fromDegrees(
msg.Heading, msg.Pitch, msg.Roll


by what means can I recover the values for heading, pitch and roll at any sampled point in time?

The code below returns a HeadingPitchRoll value:

var f = hdg.getValue(viewer.clock.currentTime)
if (f != undefined){

var g = Cesium.HeadingPitchRoll.fromQuaternion(f);


When converted to degrees from radians, the value of the heading, pitch and roll components are different to those originally added to the sampled property - presumably affected by the geographic location.

Is there a transform or other function that does the exact opposite of headingPitchRollQuaternion and returns local heading, pitch and roll or, if not, please could someone be kind enough to suggest a means by which such a process could be achieved?

It is about twenty-five years since I dealt with quaternions and even then I only pretended to understand them!

Many thanks,


Hi Hugh,

My guess is that you don’t need to use Cesium.Transforms to create the quaternion. I’m assuming property is an orientation on an entity, in which case you do not need to perform the additional transformation. You should just be able to create a Quaternion from the HeadingPitchRoll using Quaternion.fromHeadingPitchRoll.

Otherwise your code samples look straightforward and should work.