Quaternion from headingpitchroll

i have heading, pitch, and roll angle, ccw rotation about positive x-y-z.
this xyz frame is some object’s body frame, not like airplane frame. ‘up side’ is positive z.
if this object had eci to body quaternion, I want to get “eci to heading pitch roll quaternion”.
and I dont know the value of angles’ input.

real data which i have

  1. heading = 60 degree
  2. pitch = 45 degree
  3. roll = 5 degree
    // >> already convert degree to radian
  4. eci_to_body_quarternion

//the way I got quaternion down below//

const hpr = Cesium.HeadingPitchRoll(heading, -pitch, roll);
// >> “heading” because i thought down z axis is positive, and ccw rotation about negative z(up side z) in Cesium
const hpr_quaternion = Cesium.Quaternion.fromHeadingPitchRoll(hpr);
const eci_to_hpr_quaternion = Cesium.Quaternion.multiply(hpr_quaternion, eci_to_body_quarternion, new Cesium.Quaternion());

Hi there,

There is a helper function for this: Transforms.headingPitchRollQuaternion.

Hope that helps!

i’m sorry for the late thank you.
I’m still fighting this problem. so sad…

  1. Transforms.headingPitchRollQuaternion, does “fixed frame” refer ecef?
    if it refers to ecef, i don’t think I should multiply the quaternion from ‘eci to body’ quaternion directly by the quaternion obtained from Transforms.headingPitchRollQuaternion.

  2. i’m bringing the position of airplane from eci.
    can i put the eci position directly into the ‘origin’ of Transforms.headingPitchRollQuaternion?

for example,

const center = positionofairplane; //>>airplane’s position is based on eci
const headingpitchroll = new Cesium.HeadingPitchRoll(heading, pitch, roll); //>>based on airplane’s body frame(not z-down, it’s z-up)
const hpr = Cesium.Transforms.headingPitchRollQuaternion(center, headingpitchroll);