What is the difference between camera orientation and fixed frame transforms?


In our product we produce a view_matrix that represents the orientation of a drone as it takes a picture. This works fairly well, we compute the view simply like this:

 getView(): any {
    const destination = Matrix4.multiplyByPoint(this.view_matrix, Cartesian3.ZERO, new Cartesian3())
    const direction = Matrix4.multiplyByPointAsVector(this.view_matrix, Cartesian3.UNIT_Z, new Cartesian3())
    const up = Matrix4.multiplyByPointAsVector(this.view_matrix, Cartesian3.UNIT_Y, new Cartesian3())

    const view = {
      orientation: { direction, up },
    return view

However we now also have some drone positions for which we only have heading, pitch and roll, not a view_matrix. So to make things uniform I want to compute the view_matrix from the HeadingPitchRoll.

There’s some functions in Cesium.Transforms that seem to implement this, but none of them seem to produce the same results.

Below is an attempt to compute the HeadingPitchRoll from the view_matrix and you can see that the Cesium.Transforms.fixedFrameToHeadingPitchRoll function does not produce the same results.

Does anyone have an idea about what this type of view matrix is called, and maybe what set of functions do work with it? I tried a bunch of stuff, also for example extracting the Matrix3, transforming it to ENU and then using Quaternion to convert it to HeadingPitchRoll but that also failed to give the same result.

Hi there,

From your description, it looks like the “view” matrix here is either a northUpEast or eastUpNorth system, depending on what cardinal direction direction maps to.

You can use Cesium.Transforms.localFrameToFixedFrameGenerator(firstAxis, secondAxis) to generate a toFixedFrame functoin that will work for that case.

Thanks @Gabby_Getz ! I gave it a couple more tries with your suggestion. I also learned that comparing euler angles (HeadingPitchRoll) is a bad idea because there are always multiple correct solutions for any rotation so it’s not easy to see if two HeadingPitchRoll objects are identical.

I found somewhere that instead you can multiple one rotation matrix with the transpose of the other to get the difference, so that’s what I’m trying now. It seems to work when I construct two local rotation matrices and compare them this way, the result is (close to) the identity matrix.

However I’ve still not found a solution on how to use the Cesium.Transforms to construct this view matrix:

I never get similar heading pitch rolls, nor does this difference matrix ever become the identity matrix.

Oh actually I believe ENU is correct because the HeadingPitchRoll I get from it is correct, it’s just that I seem to not be able to create a similar matrix myself from a HeadingPitchRoll object.