Hi,
I’m trying to convert a Quaternion in J2000 reference frame to the one used in CesiumJs which, to my knowledge, is ECEF. I wrote this script using computeIcrfToFixedMatrix. I also have the output which I need that I calculated using STK. However, the output this script gives is not the same as the expected value. I have already tried changing the quaternion multiplication order, used no conjugation and conjugation. Is computeIcrfToFixedMatrix the proper function to use here?
const viewer = new Cesium.Viewer("cesiumContainer");
const interval = new Cesium.TimeInterval({
start : Cesium.JulianDate.fromIso8601('2024-04-08T00:00:00Z'),
stop : Cesium.JulianDate.fromIso8601('2024-04-12T00:00:00Z'),
isStartIncluded : true,
isStopIncluded : true,
});
Cesium.Transforms.preloadIcrfFixed(interval).then(function() {
var transformation = new Cesium.Matrix3();
var date = Cesium.JulianDate.fromIso8601('2024-04-08T10:00:00Z');
if (Cesium.Transforms.computeIcrfToFixedMatrix(date, transformation)) {
console.log(transformation);
const transformation_q = new Cesium.Quaternion();
Cesium.Quaternion.fromRotationMatrix(transformation, transformation_q);
var conjugated = new Cesium.Quaternion()
Cesium.Quaternion.conjugate(transformation_q, conjugated)
const fixed = new Cesium.Quaternion(-1.4418899159943832e-01, 7.8896718078524344e-02, 9.8194825164552457e-01, 9.3608085485563833e-02);
const inertial = new Cesium.Quaternion(-0.03081136788377263, -0.16108806577823861, -0.5915906321681871, 0.7893806297123871);
console.log("Fixed is", fixed)
console.log("Inertial is", inertial)
console.log("transformation is ", transformation_q);
var final = new Cesium.Quaternion()
Cesium.Quaternion.multiply(conjugated, inertial, final);
console.log("Final is", final);
} else {
console.log("Unable to compute transformation matrix for the given date.");
}
});