how to use quaternion with stk components ?

Hello,
first I congratulate the team for your work on this great project.
I'm using java components from STK in a server to generate from a TLE a satellite trajectory but I have problem to orientate the sensor in the right direction (on Earth...).

1- The satellite hang a sensor which has axes offset with the trajectory of the satellite.

JAVA code on server side: (quaternionOffSet and tle have been created before)

Sgp4Propagator propagator = new Sgp4Propagator(tle);
Axes axeSatellite = new AxesVehicleVelocityLocalHorizontal(
        propagator.getReferenceFrame(), propagator.createPoint());
Platform plateformeChild = new Platform();
AxesFixedOffset axes = new AxesFixedOffset(axeSatellite,quaternionOffSet);
plateformeChild.setOrientationAxes(axes);
AxesEvaluator evaluatorAxis=GeometryTransformer.getAxesTransformation(earth.getOrientationAxes(), axes);

2- With AxesEvaluator evaluatorAxis, the server generates the quaternions of sensor rotation and send the result to the client side of the application.

JAVA code on server side:(pasComputation is a Duration instance in STK components representing 60 seconds)

UnitQuaternion evaluation;// the quaternion of sensor rotation at each moment
ArrayList<double>quaternion; // the quaternion to save for each moment
String chrono;// the date of evaluation

for (JulianDate tampon = begin; JulianDate.lessThan(tampon, end); tampon = tampon.add(pasComputation)) {
                    evaluation=axeEvaluateur.evaluate(tampon);
quaternion=new ArrayList<double>(4);
                quaternion.add(evaluation.getX()); quaternion.add(evaluation.getY()); quaternion.add(evaluation.getZ()); quaternion.add(evaluation.getW());
            chrono=tampon.toGregorianDate().toIso8601String();
// codes to aggregate and send data to the client side (web browser)
...
}

3- In the client side (web browser), a CZML is created with the data received from server.

JAVASCRIPT code on client side: (senseur.orientation is an array listing the chrono coupled with quaternion attribute giving by server side.

var tabOrientation=new Array();
for(var i=0; i < senseur.orientation.length; i++){
var orientation=senseur.orientation[i]; tabOrientation.push(orientation['chrono']); // time in iso8601
tabOrientation.push(orientation['quaternion'][0]); //X attribute of quaternion
tabOrientation.push(orientation['quaternion'][1]);//Y attribute of quaternion
tabOrientation.push(orientation['quaternion'][2]);//Z attribute of quaternion
tabOrientation.push(orientation['quaternion'][3]);//W attribute of quaternion
        }
var czml={
    "id":sensor['name'],
    "orientation":{
      "interpolationAlgorithm":"LINEAR",
      "interpolationDegree":1,
      "unitQuaternion": tabOrientation
              },
    "position":{
       "cartographicRadians":tabPosition // list of data position with time. This is well documentated
              },
    .
                .
                . (others attributes of sensor)

        };

Questions:
In the documentation, I can't find which is the attributes order of quaternion (w,x,y,z or x,y,z,w??) and above all I can't find any data on the reference frame in which I must create the rotations in order to direct rightly the sensor.

Could you help me please?
Sincerely

Hi,

You have the right order for CZML quaternions: X, Y, Z, W. The problem you’re seeing is probably that the rotation direction is backwards. In CZML, the orientation.unitQuaternion property describes the rotation that should be applied to a vector to take it from the object’s axes to the Earth-Fixed axes. This the typical direction for model transformations in 3D graphics applications, but it’s opposite the usual STK Components direction, unfortunately. In STK Components, an AxesEvaluator evaluates the rotation that takes a vector expressed in the DefinedIn axes and expresses it in the Axes being evaluated.

So, instead of this:

AxesEvaluator evaluatorAxis=GeometryTransformer.getAxesTransformation(earth.getOrientationAxes(), axes);

Do this:

AxesEvaluator evaluatorAxis=GeometryTransformer.getAxesTransformation(axes, earth.getOrientationAxes());

Also, you may be interested to learn (if you didn’t already know) that we have a pre-release STK Components JAR (and .NET assembly for anyone using the .NET version) that makes it really easy to generate CZML from Platforms, etc. If you’d like to try it out, email your salesperson, and copy me, and we can probably get that to you.

Thanks,

Kevin

Hello,
thank you, that works

I also have some questions about unit quaternions. One thing I noticed is that specifying a unit quaternion of zero degrees of rotation (0,0,0,1) and applying to a pyramid I’m trying to configure, puts the pyramid facing due North (I think), and at around 45 degrees pitch from the earth’s surface. I never specified the attitude of the pyramid previously ,so what are the default parameters for an objects attitude? And from testing I noticed this about the quaternions:

x → pitch

y → yaw

z → roll

Is that correct?

Thanks for your help in advance.

-Jon Carmack

Here is the CZML, which you can paste into Sandcastle to see what I’m seeing. Also this czml doesn’t parse in Cesium Viewer, I just get the spinning circle. Any thoughts?

[{

“id”:“The Pyramid”,

“pyramid”:{

“show”:[

{

“boolean”:true

}

],

“material”:{

“solidColor”:{

“color”:{

“rgba”:[

190,82,118,102

]

}

}

},

“directions”:{

“unitSpherical”:[

0.29135505319563404,0.336441101854738006,2.850237600394159,0.336441101854738006,-2.850237600394159,0.336441101854738006,-0.29135505319563404,0.336441101854738006

]

}

},

“position”:{

“cartographicDegrees”:[

-137.03655,38.897669,0.0

]

},

“orientation”:{

“epoch”:“2013-04-11T11:29:35.4320000000007Z”,

“unitQuaternion”:[

0.0,0.0,0.0,1.0

]

}

}

]

After some investigation it appears that the pyramid I specified is getting the reference frame of the camera, or at least the initial position of the camera (seen by hitting the home button). What I need is to change the reference frame for the pyramid to be attached to a fixed radar object on the ground. Trying to dig around and figure it out. Any suggestions?