# J2000 to ECEF Quaternion transform

**URL:** <https://community.cesium.com/t/j2000-to-ecef-quaternion-transform/31484>\
**Category:** CesiumJS\
**Created:** [April 16, 2024, 10:13am UTC](https://community.cesium.com/t/j2000-to-ecef-quaternion-transform/31484 "2024-04-16T10:13:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![piekarski-mateusz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/piekarski-mateusz/32/15831_2.png) [@piekarski-mateusz](https://community.cesium.com/u/piekarski-mateusz)\
**Post date:** [April 16, 2024, 10:13am UTC](https://community.cesium.com/t/j2000-to-ecef-quaternion-transform/31484/1 "2024-04-16T10:13:28Z")

</div>

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.");
}

```

});
