Convert Unity Quaternion to Cesium Lat/Long or

Hello!

Fantastic tool btw! I am building an experience in Unity where you can pan / zoom / rotate earth on screen with the camera position remaining static. Before switching to Cesium, I had issues with floating point precision for Unity rotations when the globe was zoomed in at near-human scale height. Cesium solves this issue beautifully with high precision Lat / Long or ECEF coordinates represented as doubles instead of unity’s not so accurate float based Quaternions!

My issue is I already built a bunch of custom interaction logic for translating on-screen input into rotations and zooms on the map in 3D - all using quaternions. If I rotate / scale the entire Cesium Georeference gameObject I will run into the same floating point precision issues I did before.

What I’d like to do is convert all my interaction logic to be use a custom quaternion type that is a double instead of a float. Then convert the double Quaternion into the Cesium Georeference Latitude / Longitude or ECEF coordinates to rotate the globe properly.

Is there a way to convert a quaternion or direction vectors (like a forward and up vector) into Cesium Lat/Long or ECEF?

Thanks so much!

It’s almost certainly possible, but it’s hard to provide specifics without knowing more about your application logic. For example, what exactly do your quaternions represent?

The CesiumGeoreference lets you configure the point on the globe that is the origin of the Unity local coordinates, and then the Transform on that CesiumGeoreference can translate/rotate/scale the globe in the Unity world. There’s no direct support for double-precision rotations, though generally single precision is sufficient for rotations. That is, as long as you’re not using single precision to rotate the globe about th center of the Earth while the camera is zoomed in close to the surface. But when the CesiumGeoreference origin is near-ish the camera, rotating the globe about that origin with single precision will probably work out just fine.