How do I assign the quaternion and tell it that it is ECEF to body? It seems like all options require a heading/pitch/roll or a local NED/ENU frame.
2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
var position_ecef = new Cesium.Cartesian3(ecef_x, ecef_y, ecef_z);
var orientation_ecef_to_body = new Cesium.quaternion(qx, qy, qz, qw);
viewer.entities.add({
position: position_ecef,
orientation: orientation_ecef_to_body
});
How do I specify that the orientation is ECEF to body? Or do I have to convert my quaternion to something else first?
Thanks!
Steven
I have a quaternion defining the rotation to get from ECEF to body:
q_ecef_to_body = new Cesium.Quaternion(x,y,z,w);
Then I need to get the quaternion from ENU to ECEF. This is a multi-step calculation:
var origin = new Cesium.Cartesian3(0, 0, 0);
var r4_enu_to_ecef = Cesium.Transforms.eastNorthUpToFixedFrame(origin);
var r3_enu_to_ecef = Cesium.Matrix4.getRotation(r4_enu_to_ecef, new Cesium.Matrix3);
var q_enu_to_ecef = Cesium.Quaternion.fromRotationMatrix(r3_enu_to_ecef);
Now I can calculate the quaternion defining the orientation from ENU to body, which is what I need to assign to the entity's orientation. Note that multiplication order matters.
q_enu_to_body = Cesium.Quaternion.multiply(q_ecef_to_body, q_enu_to_ecef, new Cesium.Quaternion);
For example, if q_ecef_to_body is normalized, then you must normalize q_enu_to_ecef before multiplying:
q_enu_to_ecef = Cesium.Quaternion.normalize(q_enu_to_ecef, new Cesium.Quaternion);
--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.