headingPitchRollQuaternion gives wrong heading

233 views
Skip to first unread message

leight...@gmail.com

unread,
May 20, 2015, 7:36:00 PM5/20/15
to cesiu...@googlegroups.com
Hi all,

New to cesium here so sorry if this is a dumb question. I'm trying to convert lat, lon, alt, heading, pitch, roll into a quaternion for orientation of a flight, and for some reason the heading is around 80 degrees out of whack.

Here's the relevant code:

var curloc = Cesium.Cartesian3.fromDegrees(curlon, curlat, (curalt * 0.3048), Cesium.Ellipsoid.WGS84);

var quat = Cesium.Transforms.headingPitchRollQuaternion(curloc, curhead, curpitch, curroll, Cesium.Ellipsoid.WGS84);

path[1].orientation.unitQuaternion.push(time, quat.x, quat.y, quat.z, quat.w);

Do I need to alter the reference frame or something - I thought the current location would do that?

Cheers,
Leighton.

bobac...@gmail.com

unread,
May 21, 2015, 4:34:36 AM5/21/15
to cesiu...@googlegroups.com, leight...@gmail.com
Hello,
you should test this code:

var curloc = Cesium.Cartesian3.fromDegrees(curlon, curlat, (curalt * 0.3048), Cesium.Ellipsoid.WGS84);

var quat = Cesium.Transforms.headingPitchRollQuaternion(curloc, -curhead-Math.PI/2, curpitch, curroll, Cesium.Ellipsoid.WGS84);

path[1].orientation.unitQuaternion.push(time, quat.x, quat.y, quat.z, quat.w);

Indeed, for an entity, the frame used to apply a rotation is EastNorthUp frame which is local to the position. So the abscissa axis is West-> East and the ordered axis is South->North. As a trigonometric an angle is defined from abscissa axis (here West->West), you must remove 90 degrees or PI/2 radians to convert from a flight angle.
Finally the direction of trigonometric angle and flight angle are opposites.

Mike LP

unread,
May 22, 2015, 10:52:01 AM5/22/15
to cesiu...@googlegroups.com, bobac...@gmail.com, leight...@gmail.com, bobac...@gmail.com
Thanks Bobactor

leight...@gmail.com

unread,
May 24, 2015, 9:42:14 PM5/24/15
to cesiu...@googlegroups.com, leight...@gmail.com, bobac...@gmail.com
Hi Bobactor,

Thanks for the reply! The other 9 degrees was of course me using magnetic heading instead of true heading.

Regards,
Leighton.

Mike LP

unread,
May 25, 2015, 11:12:10 PM5/25/15
to cesiu...@googlegroups.com, leight...@gmail.com, leight...@gmail.com, bobac...@gmail.com
Got to love that moment when you realize you're using the wrong units, coordinate systems or conversion values...  We've all been there!
Reply all
Reply to author
Forward
0 new messages