Set camera rotation with Matrix3?

Is there a way to set the camera view to a specific rotation using a Matrix3?

Hi @Arjan14, the .setView method can input a HeadingPitchRoll, which can be constructed from a Matrix3 via a Quaternion. So overall it would look something like this (untested) code:

// Input myMatrix3
const quaternion = Cesium.Quaternion.fromRotationMatrix(myMatrix3);
const headingPitchRoll = Cesium.HeadingPitchRoll.fromQuaternion(quaternion);
camera.setView({ orientation: headingPitchRoll });

Personally, I prefer starting directly from a HeadingPitchRoll, since the values are easier to understand (see the HeadingPitchRoll Sandcastle). Are you getting a pre-constructed Matrix3 from another source?

1 Like

I get a XML file back from a camera. the usable information in the XML file from the camera is what picture is taken, the corresponding location of the picture taken (Cartesian3) and the camera rotation (heading pitch roll (in degrees) / rotation matrix3 / Omega Phi Kappa values)

I want to recreate the picture with the cesiumjs camera while using the values from the camera XML, however the only thing that is not working so far is the camera rotation, it keeps giving wrong outputs…

Maybe good to know the data in the XML is ECEF - Earth-Centered, Earth-Fixed (EPSG:4978)

Hi @Arjan14, it’s possible there are different conventions in your XML source about the direction of rotations.

Can you share a Sandcastle link that replicates the problem? Ideally we could narrow down the problem with just one sample camera location and rotation.