Entity orientation vs Primitive model matrix rotation

Hi all,
I am trying to render a position uncertainty ellipsoid around a moving object in CesiumJS. I have computed the radii of the ellipsoid and the rotation matrix to orient the ellipsoid in the ECEF (ITRF) frame using eigenvalue decomposition of the covariance matrix expressed in the ECEF frame.

I have tried implementing this in two ways:

  • By using the ellipsoid property of the Entity API; positioning the ellipsoid using the position property of the entity and orienting the ellipsoid by constructing a quaternion from the ECEF rotation matrix and using this quaternion as the entity’s orientation
  • By using the Primitive API; constructing an EllipsoidGeometry and using the modelMatrix both to position and rotate the entity in ECEF space

I would have expected these to produce identical results, but only the second approach (using the Primitive API) orients the ellipsoid correctly. What is the difference between passing a rotation (and translation) matrix as modelMatrix using the primitive API and passing an equivalent quaternion to the orientation parameter of the Entity API? Note that for the primitive API, I have tried constructing the model matrix both using the rotation matrix directly and using a quaternion constructed from the rotation matrix, and both work, so the conversion from rotation matrix to quaternion isn’t the issue. The descriptions I can find for these in the documentation are:

modelMatrix: The 4x4 transformation matrix that transforms the primitive (all geometry instances) from model to world coordinates.

orientation: Gets or sets the orientation in respect to Earth-fixed-Earth-centered (ECEF). Defaults to east-north-up at entity position.

While the solution with the Primitive API works for a single time, implementing using the Entity API would make animating the object over time much more straightforward.

Hi @derekkayhan ,
Thanks for your post and detailed explanation of the issue you are seeing.

Is it possible for you to produce a sandcastle example https://sandcastle.cesium.com/ of what you are seeing (ideally both the entity and primitive approach) to make it easier other community members to understand the issue and offer help? I think having concrete examples showing the differences between the two approaches will jumpstart the investigation/conversation. This sandcastle example might be a good scaffolding to start from for creating demos of your use case. Cesium Sandcastle

Hopefully after that community members can weigh in to help understand what is happening with the entity case.
Best,
Luke

Luke,
Thanks for your response. Happy to report this issue was closed as my fault - I was wrong that the issue wasn’t in the conversion to quaternion and hadn’t guaranteed that my rotation matrix was special orthogonal before converting. After fixing that both entity and primitive APIs work as expected with the quaternion. Sorry for the confusion!

1 Like