Mapbox-gl-native: [core] Precision loss in Transform::flyTo

Created on 13 Mar 2016  路  6Comments  路  Source: mapbox/mapbox-gl-native

Transform::flyTo loses more precision than Transform::easeTo when animating. Example:

Given point A LatLng { -45, -135 } and point B LatLng { 45, 135 }:
Transform::easeTo from point A to B: LatLng { 44.999999999695532, 135.00000000038369 }

  • Latitude precision loss: 45 - 44.999999999695532 = 3.0446756E-10
  • Longitude precision loss: 135 - 135.00000000038369 = -3.8369308E-10

Transform::flyTo from point B to A: LatLng { -44.999808628745399, -135.00024116863571 }

  • Latitude precision loss: -45 + 44.999808628745399 = -1.9137125E-4
  • Longitude precision loss: -135 + 135.00024116863571 = 2.4116863E-4

The exponent of precision loss from easeTo is -10, while flyTo is -4.

/cc @1ec5

Core archived bug

Most helpful comment

I guess one way to alleviate this issue would be converting the geographical coordinate all the way into tile coordinates, and keep using that when interpolating.

To be honest, I'd love to see easeTo and flyTo outside of the GL Native core code, and implemented externally as part of a client-side animation interface. /cc @tmpsantos

All 6 comments

This regression was caused by the additional point-latLng-point round trip added in #3301. I wonder how GL JS gets better precision out of that approach.

From #9199:

Finally, the point interpolation is tweaked so that at the end of the flying (when k === 1) it ends up at the exact end point. I didn't see any bugs related to this, but it seems like a good thing to have explicitly.

This changes the consequences of this bug: instead of ending up at the slightly wrong position at the end of flyTo, it animates to the wrong position, then suddenly snaps to the correct position at the very end.

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

I guess one way to alleviate this issue would be converting the geographical coordinate all the way into tile coordinates, and keep using that when interpolating.

To be honest, I'd love to see easeTo and flyTo outside of the GL Native core code, and implemented externally as part of a client-side animation interface. /cc @tmpsantos

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings